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

Ted Kremenek kremenek at apple.com
Tue Feb 25 11:00:08 PST 2014


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





More information about the cfe-dev mailing list