[cfe-dev] Running scan-build on multiple source files

David Blaikie dblaikie at gmail.com
Thu May 30 07:28:27 PDT 2013


On May 30, 2013 5:55 AM, "Robert Henry" <rrh at newrelic.com> wrote:
>
> I have two source files each of which is analyzed independently
> without error by scan-build.  However, the combination of the 2 files
> should trigger a complaint from scan-build, assuming scan-build has
> inter-procedural analysis spanning the two compilation units.

That assumption would be incorrect. The Clang Static Analyzer has no
cross-TU power at the moment.

> However, scan-build is silent.  Is this beyond the capabilities of
> scan-build, or am I invoking the tool incorrectly?
> (If I concatenate the source for the two files into a single file,
> then scan-build finds the expected error.)
>
> Here's how I invoke scan-build:
>   scan-build gcc a.c b.c
>
> where a.c contains:
>
> #include <stdio.h>
> extern int b (int i);
> int main (int argc, const char **argv)
> {
>   int i;
>   for (i = 0; i < 10; i++) {
>     printf ("i=%d ratio=%d\n", i, i/ b(i)); // Note zero divide here
>   }
>   return 0;
> }
>
> and b.c contains the identity function:
>  int b (int i) { return i; }
>
>
> --
> Robert Henry, New Relic
> _______________________________________________
> 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/20130530/071c0d8b/attachment.html>


More information about the cfe-dev mailing list