<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>scan-build works by substituting a dummy CC and CXX to interpose on your build system. Your makefile needs to either use these variables, or you need to reconfigure through scan-build. From <a href="http://clang-analyzer.llvm.org/scan-build.html:">http://clang-analyzer.llvm.org/scan-build.html:</a></div><div><br></div><div><p style="color: rgb(34, 34, 34); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, Helvetica, sans-serif; font-size: small; line-height: 19px; text-align: left; "></p></div><blockquote type="cite"><div><p style="color: rgb(34, 34, 34); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, Helvetica, sans-serif; font-size: small; line-height: 19px; text-align: left; ">The reason <tt style="color: rgb(0, 0, 0);">configure</tt> also needs to be run through <tt style="color: rgb(0, 0, 0);">scan-build</tt> is because <tt style="color: rgb(0, 0, 0);">scan-build</tt> scans your source files by <i>interposing</i> on the compiler. This interposition is currently done by <tt style="color: rgb(0, 0, 0);">scan-build</tt> temporarily setting the environment variable <tt style="color: rgb(0, 0, 0);">CC</tt> to <tt style="color: rgb(0, 0, 0);">ccc-analyzer</tt>. The program <tt style="color: rgb(0, 0, 0);">ccc-analyzer</tt> acts like a fake compiler, forwarding its command line arguments over to the compiler to perform regular compilation and <tt style="color: rgb(0, 0, 0);">clang</tt> to perform static analysis.</p></div></blockquote><div><br></div><div>By default, scan-build will use GCC to compile things on non-Darwin platforms. To override this, you can use the --use-cc and --use-c++ options (same as --use-analyzer).</div><div><br></div><div>Does that fix your problem?</div><div>Jordan</div><div><br></div><br><div><div>On Dec 12, 2012, at 10:17 , Peeter Joot <<a href="mailto:peeter.joot@gmail.com">peeter.joot@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">If I run scan-build on one file manually I get a report directory created as expected:<br><br><div># cat t.C</div><div>int * foo(){ int x ; return &x ;}</div><div><br></div><div># scan-build -o $HOME/scan-build --use-analyzer=`which clang` clang++ t.C -c</div>
<div>scan-build: Using '/home/peeterj/clang/optimized/bin/clang' for static analysis</div><div>t.C:1:30: warning: address of stack memory associated with local variable 'x' returned [-Wreturn-stack-address]</div>
<div>int * foo(){ int x ; return &x ;}</div><div>                             ^</div><div>1 warning generated.</div><div>t.C:1:22: warning: Address of stack memory associated with local variable 'x' returned to caller</div>
<div>int * foo(){ int x ; return &x ;}</div><div>             ~~~~~   ^      ~~</div><div>1 warning generated.</div><div>scan-build: 1 bugs found.</div><div>scan-build: Run 'scan-view /home/peeterj/scan-build/2012-12-12-3' to examine bug reports.</div>
<div><br></div><div>However, if I run this using a make rule, I see scan-build invoke make, but get the "contains no reports" message:<br><br><div># rm *.o</div><div><div># cat makefile</div><div>t.o : t.C</div>
<div>        clang++ t.C -c</div></div><div># scan-build -o $HOME/scan-build --use-analyzer=`which clang` make<br></div><div>scan-build: Using '/home/peeterj/clang/optimized/bin/clang' for static analysis</div><div>
clang++ t.C -c</div><div>t.C:1:30: warning: address of stack memory associated with local variable 'x' returned [-Wreturn-stack-address]</div><div>int * foo(){ int x ; return &x ;}</div><div>                             ^</div>
<div>1 warning generated.</div><div>scan-build: Removing directory '/home/peeterj/scan-build/2012-12-12-4' because it contains no reports.</div></div><div><br></div><div>From the scan-build man page, it appears that this is how to use this utility, but doing so just results in make being called as is.  In what way is the makefile for the project supposed to be modified to use scan-build?<br>
</div><div><br></div>-- <br>Peeter<br>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></div><br></body></html>