scan-build on Windows

Hi all,

Can anyone help in installing and running “scan-build” on Windows ?

Thanks,
Siddharth

Hi,

I never tried it myself but i can try to help you with specific problems that you're having if you disclose them.

scan-build is a Perl script, it most likely requires having Perl and a few Perl modules installed and that's it.

Hi Siddharth,

alternativly you can try this, it’s written in Python.

Regards,
Laszlo

Hi Artem, Laszlo,

There are couple of problems with scan-build :-

  1. For Windows i get the following error while running scan-build - "

“scan-build: Not supported for windows. Exiting…”:

  1. For Linux Also if i don’t install clang and related tools like scan-build in /usr/bin i am not able to generate reports ( HTML files ). Like i get the clang_sa_warnings in cmd but scan-build removes the directory saying no bugs found.

Note - I already set the CC and CXX flags to the clang compiler

Please let me know if there is any other changes i need to make in the env variable.

Thanks,
Siddharth

+Aaron because i think he uses scan-build on Windows more or less successfully. I won't have time for setting up a Windows machine for myself in the nearest future.

Could you tell us exactly what you're doing and what exactly does it print to console, more in the spirit of http://www.catb.org/~esr/faqs/smart-questions.html ?

> scan-build: Not supported for windows. Exiting...

Hmm, i don't see such string in the source code of scan-build, neither it looks like a standard Perl message.

> don't install clang and related tools like scan-build in /usr/bin i am not able to generate reports ( HTML files )

Could you provide the exact command and its exact output? Normally you don't care where is everything installed because you simply provide the path to the analyzer with `--use-analyzer`.

Hi Artem,

Couple of points to note here :-

There are two things we are trying to do :-

  1. Trying to run scan-build on Windows
  2. Running scan-build in linux and generating HTML reports in report directory

We are just trying to run scan-build with normal makefile which compiles and analyzes one test case.

The problem in the first case is that when i run the normal scan-build with build command like this :-

C:\Users\sid>perl -S scan-build -o out-dir make

scan-build: Not supported for windows. Exiting…

For the second case our aim is to just run scan-build with build command for one test case file which will be analyzed and reports will be generated in the reports directory

sid@sid-linux: /local/mnt/workspace/llvm/tools/clang/tools/scan-build/bin/scan-build --use-analyzer=/local/mnt/workspace/llvm/build/bin/clang make
scan-build: Using ’ /local/mnt/workspace/llvm/build/bin/clang’ for static analysis
/local/mnt/workspace/llvm/build/bin/…/libexec/ccc-analyzer -o test1 test1.c
test1.c:6:9: clang_sa_warning: Value stored to ‘k’ during its initialization is never read [deadcode.DeadStores]
int k = *j;
^ ~~
test1.c:6:13: clang_sa_warning: Dereference of null pointer (loaded from variable ‘j’) [core.NullDereference]
int k = *j;
^~
2 warnings generated.
scan-build: Removing directory ‘/tmp/scan-build-2019-04-10-115314-8475-1’ because it contains no reports.
scan-build: No bugs found.

It shows bugs in the cmd but doesn’t generate HTML reports. What can be the possible cause of it ? ( Note here the clang is the latest version) Is there any dependency from scan-build side that it will work with a particular version of clang ?

Thanks,

Siddharth

Makefile (123 Bytes)

test1.c (88 Bytes)

I don't fully understand what's going on in your case, but could you try removing the "CC=" line from the makefile? 'Cause it's the whole point of scan-build that it injects the analyzer through CC, so it can't work if you immediately overwrite it back. I think normally makefiles only enforce their own CC if it's unset otherwise.