Tuesday, 10 September 2013

clang++'s static analyzer and Makefiles

clang++'s static analyzer and Makefiles

I've recently discovered clang++'s static analyzer feature, and it's
fantastic for going over my code with a fine-toothed comb to find latent
bugs. I just uncomment this line in my Makefile:
CXXFLAGS += --analyze -Xanalyzer -analyzer-output=text
et voila, I'm in deep-bug-checking mode.
One minor problem with this, however, is that whenever the analyzer does
not find any problems in a particular .cpp file, doesn't produce any .o
file.
Normally that wouldn't be a big deal (I can always re-comment the above
line to build an actual executable), but usually when I see an
analyzer-warning, the first thing I want to do is try to fix the
underlying problem and then re-run make.
... which works, but since no .o files are being generated, make will
start re-analyzing all the .cpp files again from the beginning, rather
than just the .cpp files I actually modified since the previous run. This
means I end up spending rather a lot of time re-checking .cpp files that
haven't changed.
My question is, is there any way to get the static analyzer to output a .o
file (it doesn't have to be a valid object file, just any file with an
updated timestamp) so that Make will know that a "clean" .cpp file does
not need to be re-processed? (i.e. make Make work the same way it does
when doing a normal compile)

No comments:

Post a Comment