[cfe-dev] unclear about how to correctly run scan-build through make

Peeter Joot peeter.joot at gmail.com
Wed Dec 12 10:17:19 PST 2012


If I run scan-build on one file manually I get a report directory created
as expected:

# cat t.C
int * foo(){ int x ; return &x ;}

# scan-build -o $HOME/scan-build --use-analyzer=`which clang` clang++ t.C -c
scan-build: Using '/home/peeterj/clang/optimized/bin/clang' for static
analysis
t.C:1:30: warning: address of stack memory associated with local variable
'x' returned [-Wreturn-stack-address]
int * foo(){ int x ; return &x ;}
                             ^
1 warning generated.
t.C:1:22: warning: Address of stack memory associated with local variable
'x' returned to caller
int * foo(){ int x ; return &x ;}
             ~~~~~   ^      ~~
1 warning generated.
scan-build: 1 bugs found.
scan-build: Run 'scan-view /home/peeterj/scan-build/2012-12-12-3' to
examine bug reports.

However, if I run this using a make rule, I see scan-build invoke make, but
get the "contains no reports" message:

# rm *.o
# cat makefile
t.o : t.C
        clang++ t.C -c
# scan-build -o $HOME/scan-build --use-analyzer=`which clang` make
scan-build: Using '/home/peeterj/clang/optimized/bin/clang' for static
analysis
clang++ t.C -c
t.C:1:30: warning: address of stack memory associated with local variable
'x' returned [-Wreturn-stack-address]
int * foo(){ int x ; return &x ;}
                             ^
1 warning generated.
scan-build: Removing directory '/home/peeterj/scan-build/2012-12-12-4'
because it contains no reports.

>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?

-- 
Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121212/511e98a0/attachment.html>


More information about the cfe-dev mailing list