I have installed scan-build/clang version 2.9 on Ubuntu desktop. I build my C++ source code there using make . As it said scan-build would analyze a project which is built using make if you give
scan-build make
to
but after the make i see a message
scan-build: Removing '/tmp/scan-build-2013-10-16-1' because it contains no reports.
Also tried
scan-build --use-c++=/use/bin/clang++ make
Q1 - What am i doing wrong/missing here. How to use scan-build to analyze all source files.
Q2 - Is there any option to use clang++ --analyze myfile.cpp
to analyze single source file. But it gives an error about a header file included not found 'fatal' error' my.h
what is the option to clang analyze to point it to the folder having header files.
As for Q2, you should be able to use:
scan-build clang++ -c myfile.cpp
or what you suggested:
clang++ --analyze myfile.cpp
but you need to make sure that the compiler knows about all the includes and libraries (you should be able to successfully compile myfile.cpp to an object file without analysis). That includes especially the -I
directories.
There is also the -o option to scan-build, which specifies the target directory for HTML report files. Subdirectories will be created as needed to represent separate "runs" of the analyzer. If this option is not specified, a directory is created in /tmp
to store the reports, as you already know.
Another useful option would be -v
(verbose), which should print any errors that the analyzer might run into.
Last but not least, you should use the analysis with debug builds where the optimization is disabled, but more importantly where the symbols are not stripped.
Not sure if it helps, let me know ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With