VS2010 Clangification Script

Because scan-build only works with gcc-like compilers, MSVC seems awfully lacking. As such, I wrote a little (~100 LOC) script to scan VS2010 project files and run the appropriate clang based on the input.

I've attached the script. How can I make it available to the rest of the world?

Also - code review. How does that work here? Python's cool, but I'm by no means the best at it.


clangify.py (3.75 KB)

Question (vaguely off-topic, but it reminded me): does Clang build with VS
2010 yet? Last time I tried was a couple months ago, and it got caught up on
several issues. A few were clearly identifiable as preprocessor/compiler
bugs (this was before the RC of 2010; it was still in beta), so I decided
against commenting about it on the clang lists. Since you mention VS2010
though, I thought I'd ask...

Sorry I can't answer the question regarding distribution of the script.


@ Chris

I tried building it x64, and there were various NULL -> ptr conversion errors that were fixed trivially. I didn't bother with a rebuild afterward though since my VS2008 build finished with no errors.

I can't build it x86 because the headers are massively bugged on my machine. All my VS projects HAVE to be x64 or else I can't use C++ headers AT ALL. I think it should build fine though.


Extensions to common IDEs would be freakin' awesome. Microsoft's code analysis is pretty good, but it'd be great to have an open source alternative. The only thing is hooking it into CI scripts might be a bit of a pain with an IDE extension.

Hi Clark,

This is a really nice step. I'm not super fluent in Python, but I did find the code fairly intuitive. Some of the spacing between conditionals doesn't seem as tight as I am use to seeing, e.g. the extra lines at line 110, but overall it simple and readable.

The approach is a good first step, and should be useful for small VS projects. This approach will run into issues if any of the following happen:

(1) Intermediate files are needed to be generated by the build in order to compile other files

(2) Any of the source files take different compiler flags

Both (1) and (2) are the reason scan-build actually interposes itself in a regular build. That is the the ultimate truth of what the compiler really sees, and that's what's needed for accurately processing source files.

I have little experience with VS these days, and don't know what hooks it has to make it more extensible. I certainly would like to see more support for the analyzer on Windows, and would be happy to post this script on the clang-analyzer website if you were so kind to provide a brief writeup of how to use it.


Attached is my attempt at documentation (should be easily modified to fit the style of clang.llvm.org) and an updated script for easier modification.

clangify2010.py (4.25 KB)

Clangify2010.html (2.28 KB)