You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Dulma Churchill 663a923ee1
[clang] Remove dependency of mk_c_function from is_cpp
7 years ago
..
ALVar.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
ALVar.mli [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
CLintersContext.ml Add is_objc_method_exposed predicate 7 years ago
CLintersContext.mli Add is_objc_method_exposed predicate 7 years ago
CMethodProperties.ml [clang] Remove lang from the CMethodSignature that was unused 7 years ago
CMethodProperties.mli [clang] Remove lang from the CMethodSignature that was unused 7 years ago
CTLExceptions.ml [cleanup] add missing `open! IStd` 7 years ago
CTLExceptions.mli [ocamlformat] Upgrade to ocamlformat 0.4 7 years ago
CTLParserHelper.ml [ocamlformat] Upgrade base and ocamlformat 7 years ago
CTLParserHelper.mli [AL] add `--linters-validate-syntax-only` to check whether there are any syntax errors in AL files 7 years ago
CType.ml [clang] Move functions about cTypes to the CType module 7 years ago
CType.mli [clang] Move functions about cTypes to the CType module 7 years ago
CType_decl.ml [clang] Remove dependency of mk_c_function from is_cpp 7 years ago
CType_decl.mli [clang] Remove dependency of mk_c_function from is_cpp 7 years ago
Capture.ml [camel] call `Format.pp_print_*` directly where appropriate 7 years ago
Capture.mli [clang] do not run clang on unsupported commands 7 years ago
CiOSVersionNumbers.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
CiOSVersionNumbers.mli [cleanup] remove dead code 7 years ago
ClangCommand.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
ClangCommand.mli [clang] do not run clang on unsupported commands 7 years ago
ClangLogging.ml [objc frontend] Log Skipped declaration inside a class directly instead of throwing an exception 7 years ago
ClangLogging.mli [objc frontend] Log Skipped declaration inside a class directly instead of throwing an exception 7 years ago
ClangPointers.ml [cleanup] remove dead code 7 years ago
ClangPointers.mli [cleanup] remove dead code 7 years ago
ClangWrapper.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
ClangWrapper.mli Convert Reason to OCaml, and auto-format OCaml 7 years ago
ComponentKit.ml Fix List.drop 7 years ago
ComponentKit.mli Convert Reason to OCaml, and auto-format OCaml 7 years ago
README.md [docs] Extend src/clang/README.md with info about AST 7 years ago
SwitchCase.ml [clang] make switch statement translation more robust 7 years ago
SwitchCase.mli [clang] make switch statement translation more robust 7 years ago
ast_expressions.ml [clang] Refactor building method signatures 7 years ago
ast_expressions.mli [clang] Refactor building method signatures 7 years ago
cArithmetic_trans.ml cArithmetic_trans: simplification 7 years ago
cArithmetic_trans.mli [frontend] Parse binary operator using types of parameters 7 years ago
cAst_utils.ml [clang] Refactor building method signatures 7 years ago
cAst_utils.mli [clang] Refactor building method signatures 7 years ago
cContext.ml [clang] minorish improvements 7 years ago
cContext.mli [clang] minorish improvements 7 years ago
cEnum_decl.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
cEnum_decl.mli Convert Reason to OCaml, and auto-format OCaml 7 years ago
cField_decl.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
cField_decl.mli Convert Reason to OCaml, and auto-format OCaml 7 years ago
cFrontend.ml [clang] Refactor computing procnames for blocks 7 years ago
cFrontend.mli Convert Reason to OCaml, and auto-format OCaml 7 years ago
cFrontend_checkers.ml [clang] minorish improvements 7 years ago
cFrontend_checkers.mli [cleanup] remove dead code 7 years ago
cFrontend_checkers_main.ml [starvation] store issues to issue-logs like linters do 7 years ago
cFrontend_checkers_main.mli Open Core.Std by default, still use Caml Hashtbl, Map, Set 8 years ago
cFrontend_config.ml [clang] Refactor building method signatures 7 years ago
cFrontend_config.mli [clang] Refactor building method signatures 7 years ago
cFrontend_decl.ml [clang] Remove dependency of mk_c_function from is_cpp 7 years ago
cFrontend_decl.mli Convert Reason to OCaml, and auto-format OCaml 7 years ago
cFrontend_errors.ml [clang] Remove dependency of mk_c_function from is_cpp 7 years ago
cFrontend_errors.mli [linters] Add a linter for checking const pointers to Objective-C classes 7 years ago
cGeneral_utils.ml [objc] Add methods of ObjC classes and ObjC protocols to the tenv 7 years ago
cGeneral_utils.mli [objc] Add methods of ObjC classes and ObjC protocols to the tenv 7 years ago
cIssue.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
cIssue.mli [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
cLocation.ml [clang] minorish improvements 7 years ago
cLocation.mli [clang] minorish improvements 7 years ago
cMethodSignature.ml [clang] Remove lang from the CMethodSignature that was unused 7 years ago
cMethodSignature.mli [clang] Remove lang from the CMethodSignature that was unused 7 years ago
cMethod_trans.ml [clang] Remove dependency of mk_c_function from is_cpp 7 years ago
cMethod_trans.mli [clang] Refactor building method signatures 7 years ago
cModule_type.ml [capture] get rid of call graphs 7 years ago
cPredicates.ml Add predicates to check the receiver class type 7 years ago
cPredicates.mli Add predicates to check the receiver class type 7 years ago
cTL.ml Add predicates to check the receiver class type 7 years ago
cTL.mli [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
cTrans.ml [clang] Remove dependency of mk_c_function from is_cpp 7 years ago
cTrans.mli Convert Reason to OCaml, and auto-format OCaml 7 years ago
cTrans_models.ml [clang] Remove lang from the CMethodSignature that was unused 7 years ago
cTrans_models.mli [clang] Remove lang from the CMethodSignature that was unused 7 years ago
cTrans_utils.ml [clang] minorish improvements 7 years ago
cTrans_utils.mli [clang] make switch statement translation more robust 7 years ago
cType_to_sil_type.ml [clang] Refactor building method signatures 7 years ago
cType_to_sil_type.mli [clang] Refactor building method signatures 7 years ago
cVar_decl.ml [ocaml] detect and kill dead modules 7 years ago
cVar_decl.mli [clang] Added logging of caught exceptions of type IncorrectAssumption to clang frontend 7 years ago
clang_ast_extend.ml [ocamlformat] Upgrade base and ocamlformat 7 years ago
ctl_lexer.mll [al] use "quotes" for user imports 7 years ago
ctl_parser.mly [al] use "quotes" for user imports 7 years ago
ctl_parser_types.ml [ocamlformat] Upgrade to ocamlformat 0.5 7 years ago
ctl_parser_types.mli [linters] Add logging and caught exceptions to the linters 7 years ago
objcCategory_decl.ml [objc] Add methods of ObjC classes and ObjC protocols to the tenv 7 years ago
objcCategory_decl.mli [cleanup] remove dead code 7 years ago
objcInterface_decl.ml [objc] Add methods of ObjC classes and ObjC protocols to the tenv 7 years ago
objcInterface_decl.mli [cleanup] remove dead code 7 years ago
objcMethod_decl.ml [objc] Add methods of ObjC classes and ObjC protocols to the tenv 7 years ago
objcMethod_decl.mli [objc] Add methods of ObjC classes and ObjC protocols to the tenv 7 years ago
objcProperty_decl.ml [ocamlformat] Upgrade base and ocamlformat 7 years ago
objcProperty_decl.mli Add a lint rule warning about ObjC custom setters for weak properties 7 years ago
objcProtocol_decl.ml [cleanup] remove dead code 7 years ago
objcProtocol_decl.mli [cleanup] remove dead code 7 years ago
tableaux.ml [clang] minorish improvements 7 years ago
tableaux.mli [ocaml] detect and kill dead modules 7 years ago
types_lexer.mll [linters] Support reference types in the linters type parser 7 years ago
types_parser.mly [AL] New exception ALFileException with source-location info 7 years ago

README.md

Clang Front-End

This is the front-end for the clang compiler.

The main entry point is ClangWrapper.

General structure

  1. Given a compilation command from the build system, sanitize it, attach ASTExporter clang plugin to the relevant commands and run it.
  2. Parse the AST from Biniou format to OCaml data structure.
  3. (optional) Invoke translation to SIL via CFrontend.
  4. (optional) Invoke linters via CFrontend_checkers_main. More on linters

Format of the AST

OCaml data structure is defined in atd format. The clang_ast_t.atd file is generated from comments in ASTExporter.h file.

For more information, refer to the relevant documentation in facebook-clang-plugins:

Hacking on .atd file

  1. Create a simple example (example.cpp) source file with construct that needs to be exported. The smaller the better.
  2. Export extra information by changing code in libtooling/ASTExporter.h. For more information, refer to the ATD_GUIDELINES.
  3. Compile Infer with the new version of facebook-clang-plugins. Running make all from top level of Infer repository will do that. Sometimes there may be compilation errors due to .atd file changes - they need to be fixed.
  4. Use newly exported information information in the frontend.

Tips & Tricks:

  • To view the AST in a human readable version, Infer can generate .bdump file: infer -g -- clang -c example.cpp && sh example.cpp.ast.sh. Then open example.cpp.ast.bdump
  • To inspect ast dump visually: clang -c example.cpp -Xclang -ast-dump. It doesn't include all the information that Infer sees, but it's pretty concise
  • If running bdump is failing (it happens on huge sources sometimes), there is a way to view it in "Yojson" format. To do that, replace all occurrences of BiniouASTExporter with YojsonASTExporter in .ast.sh script.