问题
The binary windows installer for clang includes scan-build but when you run it with msbuild nothing happens. Even if I do something like:
"C:\Program Files\LLVM\bin\scan-build.bat" "C:\Program Files\LLVM\bin\clang.exe" test.cpp
I get something like:
scan-build: Using 'C:\Program Files\LLVM\bin\clang.exe' for static analysis
scan-build: Removed Directory '....'
scan-build: No Bugs found
Where test.cpp is:
void DivideByZero(int z){
if (z == 0) {
int x = 1 / z;
}
}
int main() {
int *i = nullptr;
*i = 42;
DivideByZero(0);
}
If I use the following I get some warnings:
"C:\Program Files\LLVM\bin\clang.exe" --analyze test.cpp
So back to my question. How does one get this to work with MSBUild? What is scan-build actually doing and should I use it or --analyze? What is the difference?
来源:https://stackoverflow.com/questions/49805188/how-do-i-use-the-clang-static-analyzer-with-msbuild-on-windows