[cfe-dev] analyzer: invoking a single analyzer from the static analysis tools.

Michael Katelman katelman at gmail.com
Tue Feb 25 11:37:17 PST 2014


Hi Ted,

Thanks for the help! I actually have a follow-up question, though. This
question came up because I was toying around with developing my own simple
checker and wanted to test it out. My first inclination was to do this in
isolation from the other checkers which is why I attempted the invocation
from my original post, but perhaps you're saying that even for a dev
situation like this just run the whole platter of checkers? Or, did you
just mean for a general usage scenario where someone isn't adding new
checkers etc.?

I just ended up using --analyze because the scan-build command I could
figure out was somewhat more verbose, needing --use-analyzer=... etc.; but,
I was mostly fumbling around trying to get it to work, so I'm sure I'm
missing a bunch of different things.

Thanks again.

-Mike


On Tue, Feb 25, 2014 at 11:00 AM, Ted Kremenek <kremenek at apple.com> wrote:

> Hi Michael,
>
> It's not recommended to run the low-level driver like this.  You can just
> use scan-build, for example:
>
>   $ scan-build clang -c /tmp/main.c
>
> or more generally
>
>   $ scan-build <compiler line>
>
> You can also use:
>
>   $ clang --analyze /tmp/main.c
>
> directly.  That's somewhat discouraged because the long-term idea is that
> the static analyzer supports global analysis.  The intention is that you
> can declare a set of files to analyze and they get analyzed together,
> whereas the latter line is clearly just analyzing a particular file using
> clang.
>
> Cheers,
> Ted
>
> On Feb 21, 2014, at 2:22 PM, Michael Katelman <katelman at gmail.com> wrote:
>
> > I was wondering if someone might be able to help me with cleanly
> invoking a single analyzer from the static analysis tools.
> >
> > I am not sure what I need to do (or, should be doing instead) in a
> situation like the one below where I've got a header like stdio.h included
> (--analyze figures it out, but then it appears that I lose the ability to
> apply a single checker) :
> >
> > %  ./Debug+Asserts/bin/clang -cc1 -analyze
> -analyzer-checker=core.DivideZero ./tmp/main.c
> >
> > ./tmp/main.c:1:10: fatal error: 'stdio.h' file not found
> > #include <stdio.h>
> >          ^
> > 1 error generated.
> >
> >  % cat ./tmp /main.c
> >
> > #include <stdio.h>
> >
> > int main( int argc, char** argv){
> >   int x = 1;
> >   int y = 0;
> >
> >   printf("%d\n", x / y);
> >
> >   return  0;
> > }
> >
> > Thanks!
> >
> > -Mike
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140225/d322d5bf/attachment.html>


More information about the cfe-dev mailing list