How do I use the clang static analyzer with msbuild on Windows?

a 夏天 提交于 2021-01-27 10:19:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!