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 c0f250c45e
[liveness] Change the model of assert functions to include the handle failure function to avoid dead store fps
7 years ago
..
ALVar.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
ALVar.mli New test for the tableaux method. 7 years ago
CLintersContext.ml [ocamlformat] Use ocamlformat from github 7 years ago
CLintersContext.mli [linters] Do not report MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE for the loop indices 7 years ago
CProcname.ml [objc] Model dispatch functions 7 years ago
CProcname.mli [linters] Include only base name of ObjC methods in the linters bug hash 7 years ago
CTLExceptions.ml [ocamlformat] Use ocamlformat from github 7 years ago
CTLExceptions.mli [ocamlformat] Use ocamlformat from github 7 years ago
CTLParserHelper.ml [ocamlformat] Use ocamlformat from github 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 [ocamlformat] Use ocamlformat from github 7 years ago
CType.mli [clang frontend] Pass type qualifiers through frontend 8 years ago
CType_decl.ml [ocamlformat] Use ocamlformat from github 7 years ago
CType_decl.mli fix infinitely-expanding types in the backend 7 years ago
Capture.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
Capture.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
CiOSVersionNumbers.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
CiOSVersionNumbers.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
ClangCommand.ml [clang] add infer C++ #include models when siof is enabled 7 years ago
ClangCommand.mli [format] Attach docstrings to be warning 50 clean, other doc fixes 8 years ago
ClangPointers.ml [ocamlformat] Use ocamlformat from github 7 years ago
ClangPointers.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
ClangWrapper.ml [ocamlformat] Use ocamlformat from github 7 years ago
ClangWrapper.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
ComponentKit.ml [style] s/_foo/foo_/ when `foo_` is not unused 7 years ago
ComponentKit.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
README.md [docs] Extend src/clang/README.md with info about AST 8 years ago
ast_expressions.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
ast_expressions.mli [clang] Remove the translation of enumerateWithBlocks that causes FPs dead store. 7 years ago
cArithmetic_trans.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
cArithmetic_trans.mli [cleanup] Remove the retain count implementation from ObjC that is unused. 7 years ago
cAst_utils.ml [linters] Adding a new predicate for in an ObjC class that is subclass of some class 7 years ago
cAst_utils.mli [linters] Adding a new predicate for in an ObjC class that is subclass of some class 7 years ago
cContext.ml [cfg] minor renamings 7 years ago
cContext.mli [cfg] minor renamings 7 years ago
cEnum_decl.ml [ocamlformat] Use ocamlformat from github 7 years ago
cEnum_decl.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cField_decl.ml [ocamlformat] Use ocamlformat from github 7 years ago
cField_decl.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cFrontend.ml [cfg] minor renamings 7 years ago
cFrontend.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cFrontend_checkers.ml [ocamlformat] Use ocamlformat from github 7 years ago
cFrontend_checkers.mli [linters] Add a linter for checking const pointers to Objective-C classes 7 years ago
cFrontend_checkers_main.ml [ocamlformat] Use ocamlformat from github 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] use a more efficient `var_decl_info` 7 years ago
cFrontend_config.mli [clang] use a more efficient `var_decl_info` 7 years ago
cFrontend_decl.ml [ocamlformat] Use ocamlformat from github 7 years ago
cFrontend_decl.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cFrontend_errors.ml [style] s/_foo/foo_/ when `foo_` is not unused 7 years ago
cFrontend_errors.mli [linters] Add a linter for checking const pointers to Objective-C classes 7 years ago
cGeneral_utils.ml [infer][PR] [C/C++] Encode filename into the Procname of global initializers 7 years ago
cGeneral_utils.mli [clang] use a more efficient `var_decl_info` 7 years ago
cIssue.ml [ocamlformat] Use ocamlformat from github 7 years ago
cIssue.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cLocation.ml [ocamlformat] Use ocamlformat from github 7 years ago
cLocation.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cMethod_signature.ml [ocamlformat] Use ocamlformat from github 7 years ago
cMethod_signature.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cMethod_trans.ml [cleanup] remove language from ProcAttributes 7 years ago
cMethod_trans.mli [cfg] minor renamings 7 years ago
cModule_type.ml [cfg] minor renamings 7 years ago
cPredicates.ml [style] s/_foo/foo_/ when `foo_` is not unused 7 years ago
cPredicates.mli [linters] Ading predicate is_in_objc_class_named and make a verbose rule more targeted 7 years ago
cTL.ml [style] s/_foo/foo_/ when `foo_` is not unused 7 years ago
cTL.mli Add a lint rule warning about ObjC custom setters for weak properties 7 years ago
cTrans.ml [liveness] Change the model of assert functions to include the handle failure function to avoid dead store fps 7 years ago
cTrans.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cTrans_models.ml [objc] Model dispatch functions 7 years ago
cTrans_models.mli [objc] Model dispatch functions 7 years ago
cTrans_utils.ml [objc] Model dispatch functions 7 years ago
cTrans_utils.mli [objc] Model dispatch functions 7 years ago
cType_to_sil_type.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
cType_to_sil_type.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
cVar_decl.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
cVar_decl.mli [clang] translate vars captured by lambda 8 years ago
clang_ast_extend.ml [ocamlformat] Use ocamlformat from github 7 years ago
ctl_lexer.mll Add a lint rule warning about ObjC custom setters for weak properties 7 years ago
ctl_parser.mly Add a lint rule warning about ObjC custom setters for weak properties 7 years ago
ctl_parser_types.ml [ocamlformat] Use ocamlformat from github 7 years ago
ctl_parser_types.mli New test for the tableaux method. 7 years ago
objcCategory_decl.ml [ocamlformat] Use ocamlformat from github 7 years ago
objcCategory_decl.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
objcInterface_decl.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
objcInterface_decl.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
objcProperty_decl.ml Add a lint rule warning about ObjC custom setters for weak properties 7 years ago
objcProperty_decl.mli Add a lint rule warning about ObjC custom setters for weak properties 7 years ago
objcProtocol_decl.ml [ocamlformat] Use ocamlformat from github 7 years ago
objcProtocol_decl.mli Convert Reason to OCaml, and auto-format OCaml 8 years ago
tableaux.ml [ocamlformat] Upgrade ocamlformat to v0.2 from opam 7 years ago
tableaux.mli New test for the tableaux method. 7 years ago
types_lexer.mll [linters] Support reference types in the linters type parser 8 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.