[cfe-dev] I get no reports from running "scan-build <args...> make -k

Duglas Mikle drongoa6 at yandex.ru
Mon Jun 24 01:44:56 PDT 2013


Hi Ted,

my name is Mikhail, I'm trying to adopt clang for my project. It works with "C", but I couldn't achieve success with C++.
I saw similar thread, tried set environment, without success yet. 
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-September/011194.html
Let me describe what I have and if you can help it will be very appreciated.


linux - Ubuntu
g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3

clang --version
clang version 3.3 (tags/RELEASE_33/final)

which clang
/usr/local/bin/clang

/usr/share/clang/scan-build/scan-build

People doesn't like get letters in attachment, so I used several source files from here:
http://mrbook.org/tutorials/make/


Then create in the same directory Makefile:
all:
	g++ main.cpp hello.cpp factorial.cpp -o hello

allclang:
	clang++ main.cpp hello.cpp factorial.cpp -o hello


clean:
	rm -rf hello 

Then create script for scan-build:
clang_example.sh
===========
#!/bin/sh

export CC="/usr/share/clang/scan-build/ccc-analyzer"
export CXX="/usr/share/clang/scan-build/c++-analyzer"
export CXXAnalyzer="c++-analyzer"

#CLANG_PATH="--use-analyzer=/usr/local/bin/clang++"
CLANG_PATH="--use-analyzer=/usr/share/clang/scan-build/c++-analyzer"
VERBOSE="-v -v"

export PATH=/usr/share/clang/scan-build:/usr/local/bin:$PATH
export CCC_ANALYZER_CPLUSPLUS=1


export LDPLUSPLUS=/usr/share/clang/scan-build/c++-analyzer

scan-build $VERBOSE $CLANG_PATH  -o ./scan_report -k -V make clean allclang
===========

I did small tuning in source files:
1) added "using namespace std;" for successful compilation and then
2) factorial.cpp
replace
return(n * factorial(n-1));
to
return(n * factorial(n-1)/0);

After these changes I get:
----------------------------------------
> make allclang
clang++ main.cpp hello.cpp factorial.cpp -o hello
factorial.cpp:5:27: warning: division by zero is undefined [-Wdivision-by-zero]
        return(n * factorial(n-1)/0);
                                 ^~
1 warning generated.
-----------------------------------------
Perfect! Clan++ works and point to the Error, but

>sh clang_example.sh

doesn't create report which contains the error.
scan-build: Removing directory 'SimpleProject/scan_report/2013-06-24-1' because it contains no reports.

I tried different workarounds, but it doesn't work. May be I need to install all tools in /usr/bin/ and try to do it one more time, I don't know.
Ted, if you have time please help to resolve the issue.

Best Regards,
Mikhail.



More information about the cfe-dev mailing list