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.

2 lines
6.6 KiB

This file contains ambiguous Unicode characters!

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>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>index (infer.index)</title><link rel="stylesheet" href="../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc %%VERSION%%"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> infer</nav><nav class="toc"><ul><li><a href="#library-infer">Library infer</a><ul><li><a href="#absint/">absint/</a></li><li><a href="#backend/">backend/</a></li><li><a href="#checkers/">checkers/</a></li><li><a href="#clang/">clang/</a><ul><li><a href="#general-structure">General structure</a></li><li><a href="#format-of-the-ast">Format of the AST</a></li><li><a href="#hacking-on-the-.atd-file">Hacking on the <code>.atd</code> file</a></li></ul></li><li><a href="#eradicate/">eradicate/</a></li><li><a href="#java/">java/</a></li><li><a href="#infer-executable">infer executable</a></li></ul></li></ul></nav></header><h2 id="library-infer"><a href="#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: <a href="InferModules/index.html"><code>InferModules</code></a>.</p><p>The modules are split into several directories in the source tree of infer.</p><h3 id="absint/"><a href="#absint/" class="anchor"></a>absint/</h3><p>Code + utilities for the Infer.AI abstract interpretation framework. Start at <a href="InferModules/AbstractInterpreter/index.html"><code>InferModules.AbstractInterpreter</code></a>.</p><h3 id="backend/"><a href="#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 <a href="InferModules/InferAnalyze/index.html"><code>InferModules.InferAnalyze</code></a>.</p><p>The module <a href="InferModules/InferPrint/index.html"><code>InferModules.InferPrint</code></a> is used to export the analysis results.</p><h3 id="checkers/"><a href="#checkers/" class="anchor"></a>checkers/</h3><p>Transfer functions, abstract domains, and checker configuration.</p><h3 id="clang/"><a href="#clang/" class="anchor"></a>clang/</h3><p>This is the frontend for the clang compiler. The main entry point is <a href="InferModules/ClangWrapper/index.html"><code>InferModules.ClangWrapper</code></a>.</p><h4 id="general-structure"><a href="#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 <a href="InferModules/CFrontend/index.html"><code>InferModules.CFrontend</code></a>.</li><li>If enabled, invoke linters via <a href="InferModules/CFrontend_checkers_main/index.html"><code>InferModules.CFrontend_checkers_main</code></a>. More on linters here: <a href="http://fbinfer.com/docs/linters.html">http://fbinfer.com/docs/linters.html</a>.</li></ol><h4 id="format-of-the-ast"><a href="#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 <a href="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><a href="https://github.com/facebook/facebook-clang-plugins/blob/master/libtooling/ATD_GUIDELINES.md"><code>libtooling/ATD_GUIDELINES.md</code></a></li><li><a href="https://github.com/facebook/facebook-clang-plugins/blob/master/clang-ocaml/README.md"><code>clang-ocaml/README.md</code></a></li></ul><h4 id="hacking-on-the-.atd-file"><a href="#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 <a href="https://github.com/facebook/facebook-clang-plugins/blob/master/libtooling/ASTExporter.h"><code>libtooling/ASTExporter.h</code></a>. For more information, refer to the <a href="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 &amp; 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 &amp;&amp; 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 &quot;Yojson&quot; format. To do that, replace all occurrences of <code>BiniouASTExporter</code> with <code>YojsonASTExporter</code> in the <code>.ast.sh</code> script.</li></ul><h3 id="eradicate/"><a href="#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 <a href="http://fbinfer.com/docs/eradicate.html">http://fbinfer.com/docs/eradicate.html</a>.</p><p>The main entry point is module <a href="InferModules/Eradicate/index.html"><code>InferModules.Eradicate</code></a>.</p><h3 id="java/"><a href="#java/" class="anchor"></a>java/</h3><p>Java Frontend; this is the frontend for Java compilers.</p><p>The main entry point is <a href="InferModules/JMain/index.html"><code>InferModules.JMain</code></a>.</p><h3 id="infer-executable"><a href="#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>