Clang, which use LLVM infrastructure, is a compiler for the C language family. His goal is to offer a moder alternative to GCC. With Clang come a pretty cool static analyser. Here is how to use it for Gimp.
A small disclaimer before, I shamefully copied and adapted the procedure given by Campbell Barton, form the Blender team. (http://wiki.blender.org/index.php/User:Ideasman42/BlenderClang).
I first tried the LLVM provided by ArchLinux, but the compilation ended with a fatal error. It goes flawlessly with the development version. To fetch it, Campbell Barton’s script works well.
First, we need to add LLVM’s binary to the PATH:
The only difference with a classic GCC compilation, is that we explicitly ask to use Clang’s compiler:
If you just want to compile, the procedure doesn’t change.
If you want to run a static analyse, you have to use scan-build:
Just be aware that a static analyse will take a lot of time (3h40 with my Core 2 Duo E4500).
The static analyzer of Clang will probably find a lot of bug in the code. Yes, there is false positive, but it’s globally remarkably well done ! You can find here the result of the analyse of master i did today: http://pellelatarte.fr/dawa/gimp-llvm/
Hi Michael,
I think that for a correct analysis some filter are needed. I have analyzed some “Dereference of null pointer” alert and in every case the instruction is preceded by a the functions g_return_if_fail(), g_return_val_if_fail(). So if I’m not wrong those are all false positive.
Malix
I agree with that, and I already filed a bug for that in the LLVM bug tracker:
http://llvm.org/bugs/show_bug.cgi?id=8962
Thanks for confirmation anyway =)
I hope this will be solved, so we’ll have a better static analyser