[cfe-dev] running analysis across translation units

Ella Oikawa via cfe-dev cfe-dev at lists.llvm.org
Sun May 26 19:05:42 PDT 2019


Hi Aaron,

According to my investigation, you can enable CTU analysis with
`experimental-enable-naive-ctu-analysis=true` and `ctu-dir` parameters when
executing clang.
And before your analysis, you should create the external definition mapping
file with `clang-extdef-mapping` or `clang-func-mapping` (depending on your
clang's version, see clang/tools/).
With the mapping file, CTU analysis can find the desired FunctionDecls
outside current TU when CTU analysis is enabled.

An example of invoking clang with CTU analysis enabled:
```
$ clang++ -cc1 -analyze -analyzer-checker=YOUR_REQUIRED_CHECKERS -o
OUTPUT_DIRECTORY/
-analyzer-config experimental-enable-naive-ctu-analysis=true
-analyzer-config ctu-dir=PATH_TO_FIND_MAPPING_FILE/ FILE_TO_BE_ANALYZED.cpp
```

The latest version of CTU analysis is now under merging, hope there will be
some official documents someday.

Hope this helps.

Regards,
Ella

AAA C via cfe-dev <cfe-dev at lists.llvm.org> 于2019年5月26日周日 下午2:36写道:

> Hello,
>
> Is there a way to analyze multiple translation units / files using clang?
> I'm trying to implement a simple analysis to match up each function call to
> its potential FunctionDecls, where the decls might be defined in multiple
> files.
>
> Thanks,
> Aaron
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190527/f92009ba/attachment.html>


More information about the cfe-dev mailing list