[cfe-dev] Running clang with a smaller set of Checkers
Jordan Rose
jordan_rose at apple.com
Thu Mar 7 09:04:20 PST 2013
Ah, I see. If you're only running syntax-based checkers (checkASTDecl, checkASTCodeBody, and checkEndOfTranslationUnit), then it's perfectly fine to run without the core checkers.
We've been meaning to make it so the core checkers are enabled by default (and can't be disabled) if any other path-sensitive checkers are enabled, but for now --analyze still has to enable them explicitly.
As I mentioned below, you can make sure the -analyzer-disable-checker option reaches the analyzer by using "-Xclang -analyzer-disable-checker=core,unix,cplusplus,osx,deadcode".
Jordan
On Mar 7, 2013, at 3:47 , Yuval Shahar <yuval.shahar.007 at gmail.com> wrote:
> Hi Jordan.
>
> Thanks. I am still not sure that my first pass requires the core checkers. I am trying to collect some statistics like the overall number of classes, methods and variables. However, the first pass' output is a simple text file; I am certain, this is not quite the solid design we'll be looking for.
>
> What you wrote helps a lot, but since you recommend using '--analyze', is there a way to use '--analyze' and then override some of its options with a later '-cc1 -analyzer-disable-checker=core'?
>
> Thanks, Yuval.
>
>
>
> On Wed, Mar 6, 2013 at 7:20 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>
> 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/20130307/27d0fdde/attachment.html>
More information about the cfe-dev
mailing list