since the CTU functionality is not yet part of the mainline clang (review ongoing), you will need to clone our patched version of clang5
please use the following llvm commit revision to compile clang:
Branch ctu-clang5 ->
LLVM commit 657c31173ea30090583e40c7a9204561d9c2d8c4
when you compiled clang successfully you should have a “clang-func-mapping” binary in the <build_dir>/bin directory.
Then create a codechecker package as described here
Add <LLVM_BUILD_DIR>/bin to your path e.g.: export PATH=<LLVM_BUILD_DIR>/bin:$PATH
so CodeChecker will find this new CTU patched version of clang.
If all went fine you start CodeChecker analyze –help and it will print:
cross translation unit analysis arguments:
These arguments are only available if the Clang Static Analyzer supports
Cross-TU analysis. By default, no CTU analysis is ran when 'CodeChecker
analyze' is called.
--ctu, --ctu-all Perform Cross Translation Unit (CTU) analysis, both
'collect' and 'analyze' phases. In this mode, the
extra files created by 'collect' are cleaned up after
--ctu-collect Perform the first, 'collect' phase of Cross-TU
analysis. This phase generates extra files needed by
CTU analysis, and puts them into '<OUTPUT_DIR>/ctu-
dir'. NOTE: If this argument is present, CodeChecker
will NOT execute the analyzers!
--ctu-analyze Perform the second, 'analyze' phase of Cross-TU
analysis, using already available extra files in
'<OUTPUT_DIR>/ctu-dir'. (These files will not be
cleaned up in this mode.)
--ctu-on-the-fly If specified, the 'collect' phase will not create the
extra AST dumps, but rather analysis will be ran with
an in-memory recompilation of the source files.
Then you can say to analyze your code:
CodeChecker log -b “make” -o compilation.json
CodeChecker analyze compilation.json –ctu-all -o reports
then print the reports
CodeChecker parse ./reports
(For more howto see:
I hope this helps.
From: cfe-dev [mailto:[hidden email]]
On Behalf Of Siddharth Shankar Swain via cfe-dev
Sent: 2017. szeptember 20. 16:17
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Cross translational unit analysis in codechecker
can anyone tell how to use codechecker
cross translational unit analysis flag for analysis across translational unit ?