Search code examples
c++clangclang-static-analyzer

How to make clang-check to generate html reports?


I am running clang-check 5.0 on centos 7.5 to run the static analysis. How can I set clang-check to generate html reports? Plist files can be generated fine.

Here's the command I have used, but it does not work. No html file is generated. Thanks.

clang-check -analyze -p compile_commands.json -extra-arg=-Xanalyzer -extra-arg=-analyzer-output=html -extra-arg=-o=html_output xxx.cpp

warning: could not create file in 'xxx.plist': Not a directory

Solution

  • Your command-line arguments are correct to make clang-check generate HTML reports. However, the ClangTool frontend will filter out the -o arguments no matter it is captured from the compilation database or added in command-line arguments. And the value of -o argument will be replaced as xxx.plist in your case.

    If xxx.plist is an existing file, you need to remove it first. And clang-check will automatically create a folder named xxx.plist with all HTML reports for file xxx.cpp generated inside.

    There is no way to override the default -o argument currently. Fortunately, with my patch, it will be available in clang-check 14 via argument -analyzer-output-path.