This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<!DOCTYPE html>
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><title>index (infer.index)</title><linkrel="stylesheet"href="../odoc.css"/><metacharset="utf-8"/><metaname="generator"content="odoc %%VERSION%%"/><metaname="viewport"content="width=device-width,initial-scale=1.0"/><scriptsrc="../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><divclass="content"><header><nav><ahref="../index.html">Up</a>– infer</nav><navclass="toc"><ul><li><ahref="#library-infer">Library infer</a><ul><li><ahref="#absint/">absint/</a></li><li><ahref="#backend/">backend/</a></li><li><ahref="#checkers/">checkers/</a></li><li><ahref="#clang/">clang/</a><ul><li><ahref="#general-structure">General structure</a></li><li><ahref="#format-of-the-ast">Format of the AST</a></li><li><ahref="#hacking-on-the-.atd-file">Hacking on the <code>.atd</code> file</a></li></ul></li><li><ahref="#eradicate/">eradicate/</a></li><li><ahref="#java/">java/</a></li><li><ahref="#infer-executable">infer executable</a></li></ul></li></ul></nav></header><h2id="library-infer"><ahref="#library-infer"class="anchor"></a>Library infer</h2><p>These are the modules used by infer that are not packaged into sub-libraries.</p><p>The entry point of this library is the module: <ahref="InferModules/index.html"><code>InferModules</code></a>.</p><p>The modules are split into several directories in the source tree of infer.</p><h3id="absint/"><ahref="#absint/"class="anchor"></a>absint/</h3><p>Code + utilities for the Infer.AI abstract interpretation framework. Start at <ahref="InferModules/AbstractInterpreter/index.html"><code>InferModules.AbstractInterpreter</code></a>.</p><h3id="backend/"><ahref="#backend/"class="anchor"></a>backend/</h3><p>The backend is responsible for the analysis of a project starting from an intermediate representation stored in the results directory, typically <code>infer-out</code>.</p><p>The entry point for the analysis is the module <ahref="InferModules/InferAnalyze/index.html"><code>InferModules.InferAnalyze</code></a>.</p><p>The module <ahref="InferModules/InferPrint/index.html"><code>InferModules.InferPrint</code></a> is used to export the analysis results.</p><h3id="checkers/"><ahref="#checkers/"class="anchor"></a>checkers/</h3><p>Transfer functions, abstract domains, and checker configuration.</p><h3id="clang/"><ahref="#clang/"class="anchor"></a>clang/</h3><p>This is the frontend for the clang compiler. The main entry point is <ahref="InferModules/ClangWrapper/index.html"><code>InferModules.ClangWrapper</code></a>.</p><h4id="general-structure"><ahref="#general-structure"class="anchor"></a>General structure</h4><ol><li>Given a compilation command from the build system, sanitize it, attach <code>ASTExporter</code> clang plugin to the relevant commands and run it.</li><li>Parse the AST (Abstract Syntax Tree) from the Biniou format into an OCaml data structure.</li><li>If enabled, invoke translation to <code>SIL</code> via <ahref="InferModules/CFrontend/index.html"><code>InferModules.CFrontend</code></a>.</li><li>If enabled, invoke linters via <ahref="InferModules/CFrontend_checkers_main/index.html"><code>InferModules.CFrontend_checkers_main</code></a>. More on linters here: <ahref="http://fbinfer.com/docs/linters.html">http://fbinfer.com/docs/linters.html</a>.</li></ol><h4id="format-of-the-ast"><ahref="#format-of-the-ast"class="anchor"></a>Format of the AST</h4><p>The OCaml data type is defined in <code>atd</code> format. The <code>clang_ast_t.atd</code> file is generated from the comments in the <ahref="https://github.com/facebook/facebook-clang-plugins/blob/master/libtooling/ASTExporter.h"><code>ASTExporter.h</code></a> file.</p><p>For more information, refer to the relevant documentation in <code>facebook-clang-plugins</code>:</p><ul><li><ahref="https://github.com/facebook/facebook-clang-plugins/blob/master/libtooling/ATD_GUIDELINES.md"><code>libtooling/ATD_GUIDELINES.md</code></a></li><li><ahref="https://github.com/facebook/facebook-clang-plugins/blob/master/clang-ocaml/README.md"><code>clang-ocaml/README.md</code></a></li></ul><h4id="hacking-on-the-.atd-file"><ahref="#hacking-on-the-.atd-file"class="anchor"></a>Hacking on the <code>.atd</code> file</h4><ol><li>Create a simple example (<code>example.cpp</code>) source file with construct that needs to be exported. The smaller the better.</li><li>Export the extra information by changing the code in <ahref="https://github.com/facebook/facebook-clang-plugins/blob/master/libtooling/ASTExporter.h"><code>libtooling/ASTExporter.h</code></a>. For more information, refer to the <ahref="https://github.com/facebook/facebook-clang-plugins/blob/master/libtooling/ATD_GUIDELINES.md"><code>ATD_GUIDELINES</code></a>.</li><li>Compile Infer with the new version of <code>facebook-clang-plugins</code>. Running <code>make</code> from top level of Infer repository will do that. Sometimes there may be compilation errors due to <code>.atd</code> file changes - they need to be fixed.</li><li>Use newly exported information information in the frontend.</li></ol><p>Tips & Tricks:</p><ul><li>To view the AST in a human readable version, Infer can generate <code>.bdump</code> file: <code>infer -g -- clang -c example.cpp && sh example.cpp.ast.sh</code>. Then open <code>example.cpp.ast.bdump</code>.</li><li>To inspect AST dump visually: <code>clang -c example.cpp -Xclang -ast-dump</code>. It doesn't include all the information that Infer sees, but it's pretty concise</li><li>If running <code>bdump</code> 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 <code>BiniouASTExporter</code> with <code>YojsonASTExporter</code> in the <code>.ast.sh</code> script.</li></ul><h3id="eradicate/"><ahref="#eradicate/"class="anchor"></a>eradicate/</h3><p>Eradicate <code>@Nullable</code> Checker</p><p>Eradicate is a type checker for <code>@Nullable</code> annotations for Java. The goal is to eradicate null pointer exceptions. See the online docs at <ahref="http://fbinfer.com/docs/eradicate.html">http://fbinfer.com/docs/eradicate.html</a>.</p><p>The main entry point is module <ahref="InferModules/Eradicate/index.html"><code>InferModules.Eradicate</code></a>.</p><h3id="java/"><ahref="#java/"class="anchor"></a>java/</h3><p>Java Frontend; this is the frontend for Java compilers.</p><p>The main entry point is <ahref="InferModules/JMain/index.html"><code>InferModules.JMain</code></a>.</p><h3id="infer-executable"><ahref="#infer-executable"class="anchor"></a>infer executable</h3><p>You'll find the infer binary in infer.ml. It is not part of this library.</p></div></body></html>