[cfe-dev] Running clang with a smaller set of Checkers

Jordan Rose jordan_rose at apple.com
Wed Mar 6 09:20:04 PST 2013


On Mar 6, 2013, at 3:18 , YuvalShahar <yuval.shahar.007 at gmail.com> wrote:

> Hi,
> 
> I wrote a checker which I need to run on all translation units, then
> summarize its output and re-run clang on all translation units
> (inter-procedural by a pass to collect data and a second pass using it).
> 
> I wish to run clang for the first pass, disabling all checkers but my data
> collector, but I fail to do this. Any idea?
> 
> I could change the core checkers set (checkers.td), but having to recompile
> clang and hold two clang versions for thew two passes seems excessive.

Hi, Yuval. The analyzer will not run properly if the "core" checkers are not run—they help prune infeasible paths. (For example, if you divide by a number 'x', we know that 'x' is non-zero after that point.) However, the other checkers can be turned off using an internal option -analyzer-disable-checker=unix,osx,cplusplus,deadcode; in order to make sure this option reaches the analyzer, you'll have to prepend it with -Xclang.

If you want to be 100% sure all the other checkers are off, you can see the command line generated by clang --analyze by adding -### to the end. Then you can strip out all the checkers besides "core", and add your own. However, I don't recommend saving the resulting command line because new options are added all the time, and while "clang --analyze" will always do the right thing, "clang -cc1 -analyze..." may be missing some critical options down the line.

Does this solve your problem?
Jordan

P.S. I'd be interested in seeing your setup once you've finished it. General cross-translation-unit analysis is something still off in the future for the analyzer, but when we get there some day we'll need a solid design.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130306/5a596aa9/attachment.html>


More information about the cfe-dev mailing list