[cfe-dev] Static Analyzer Question

Brugnoni Silvano sbrugnon at hsr.ch
Tue Mar 31 09:09:39 PDT 2015


Hi all,

 I’m working on a static analysis tool to detect low-level data races in C++ code. The analysis I’m trying to implement requires a control flow graph (CFG) of the entire program.

I’m currently working the construction of this whole-program CFG using the Clang Static Analyzer. I’m aware that cross-translation unit IPA is not supported by the static analyzer by default. But I think it should be possible to extract the CFG of each translation unit independently using a custom checker, and then merge them together into a whole-program CFG afterwards. I plan to perform the merging and the subsequent analysis from a standalone tool based on LibTooling. This brings me to my question:

Is it possible to run a checker from a clang standalone tool without having to compile it into clang? From what I can tell, the AnalysisConsumer, which  is in charge of running the path-sensitive analyses, is located in an anonymous namespace and there is no way of passing it an additional checker to execute. I would appreciate it if you could clarify this.

Since I have not been able to run a checker from a clang standalone tool myself, I explored a different route: I tried to instantiate the clang::into::ExprEngine and its dependencies from within a custom FrontendAction in order to obtain the translation-unit CFG this way. However, I keep getting Segmentation Faults, and sometimes even Bus Errors when I run this program, depending on the exact code and compiler optimization settings. These Errors are probably caused by my lack of understanding of the clang code base, and I’m still investigating what is missing/wrong with my code. Still, I attached a simplified version of the program. Any advice is appreciated as well.

Regards,
Silvano

-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: application/octet-stream
Size: 3666 bytes
Desc: main.cpp
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150331/418268b1/attachment.obj>


More information about the cfe-dev mailing list