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

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

Hi Mikhail,

You seem to have some custom set up. Have you tried downloading the latest analyzer package and following the instructions on running scan-build on your project?
http://clang-analyzer.llvm.org/scan-build.html

Cheers,
Anna.

Hi Anna,

Problem was resolved:
I added files scanview.css and sorttable.js into /usr/bin and put all other tools there also (clang++, scan-build…)
After that I could run scan-build successfully and got report.
Thank you for help!

BR,
Mikhail.

Hi,

I am having the same problem.

I moved everything under the directory where the binaries are installed
as it works for Mikhail but I still don’t get the report.

Running scan-build on this test code

int main(int argc, char** argv)
{
uint8_t array[12];
uint8_t* ptr;
uint8_t i = 10/0;

array[3] = *ptr;

for (uint8_t i = 0; i < 13; i++) {
printf("%d\n", array[i]);
array[i] = 1;
}

printf("%d\n", ptr[1]);
ptr = array;

return 0;

}

$ scan-build --use-analyzer=which c++-analyzer -V -o . make
scan-build: Using ‘/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/c+±analyzer’ for static analysis
clang++ test.cpp -o test
test.cpp:18:19: warning: division by zero is undefined [-Wdivision-by-zero]
uint8_t i = 10/0;
^~
1 warning generated.
scan-build: Removing directory ‘/home/xxxx/programming/clang-check-test/2013-06-27-1’ because it contains no reports.
scan-build: No bugs found.

Running it with strace show the following

stat64("/home/xxxx/programming/clang-check-test/2013-06-27-1/failures", 0x94ea0c4) = -1 ENOENT (No such file or directory)
write(1, “scan-build: Removing directory '”…, 118scan-build: Removing directory ‘/home/xxxx/programming/clang-check-test/2013-06-27-1’ because it contains no reports.
) = 118

For some reason failures is not created.

Any hints?

Hi Salvatore,

please do following:

$which clang++
/usr/bin/clang++ (should be here. I hope that the limitation isn’t mandatory, but it will be much easier)

$which scan-build

/usr/bin/scan-build

$ls /usr/bin/scanview.css

/usr/bin/scanview.css

$ls /usr/bin/sorttable.js

/usr/bin/sorttable.js

All these files should be in place. If Yes, then your installation was successful.
And next:

export CXX=clang++

then, verify your Makefile

Thanks for your reply Mikhail.

I double checked that everything is in the same installation directory
but still nothing.

$ which scan-build
/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/scan-build

$ which clang++
/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/clang++

$ ls /home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/scanview.css
/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/scanview.css

$ ls /home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/sorttable.js
/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/sorttable.js

My makefile is as silly as

$ cat Makefile

test: test.cpp
clang++ test.cpp -o test

$ scan-build -o ./ make
scan-build: Using ‘/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin/clang’ for static analysis
clang++ test.cpp -o test
test.cpp:18:19: warning: division by zero is undefined [-Wdivision-by-zero]
uint8_t i = 10/0;
^~
1 warning generated.
scan-build: Removing directory ‘/home/xxxx/programming/clang-check-test/2013-06-27-1’ because it contains no reports.
scan-build: No bugs found.

clang version is 3.3
host is Ubuntu 12.04

Thanks again,
Salvatore

Ok. Let’s try step by step.

  1. PATH=/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin:$PATH
  2. export CXX=clang++
  3. Important: mofify your Makefile:

test: test.cpp
clang++ test.cpp -o test

as

test: test.cpp
$(CXX) test.cpp -o test

And read:

* The 1st paragraph under "Will it work with any build system?" of
  http://clang-analyzer.llvm.org/scan-build.html

* "Variables for specifying commands" in the "Makefile conventions"
  section of the GNU Make manual:
  http://www.gnu.org/software/make/manual/html_node/Command-Variables.html

* "Variables used by implicit rules" in the GNU Make manual:
  http://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html#index-CXX-868

I definitely should start reading instead of just scrolling down
quickly documentation ... :slight_smile:

It works just fine.

Thanks to both.

S.

Ok. Let’s try step by step.

  1. PATH=/home/xxxx/programming/llvm-bld/Release+Debug+Asserts/bin:$PATH
  2. export CXX=clang++
  3. Important: mofify your Makefile:
    test: test.cpp
    clang++ test.cpp -o test

as

test: test.cpp
$(CXX) test.cpp -o test

And read:

I definitely should start reading instead of just scrolling down
quickly documentation … :slight_smile:

Some “evident” things became evident only after issue became resolved, not earlier :wink:

It works just fine.

Great!

BR,
Mikhail.