문제

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)

도움이 되었습니까?

해결책

Check out the clang static analyzer page, and get the package there for download. You can use the included scan-build tool to do what you're trying.

The normal way to use is to get rid of the flags you have above and just run:

$ scan-build make whatever

And it should 'just work'. You might need to pass some more flags or set some environment variables if you don't use standard make variable names.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top