Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang scan-build reports with compiler warnings?

clang's scan-build driver for the static analyzer generates pretty html reports. But these only contain the issues the analyzer finds.

Is there way to generate the same kind of reports for warnings (and errors) from the compiler itself?

like image 722
dantje Avatar asked Oct 26 '12 18:10

dantje


People also ask

What is Clang-tidy check?

Clang-tidy is a standalone linter tool for checking C and C++ source code files. It provides an additional set of compiler warnings—called checks—that go above and beyond what is typically included in a C or C++ compiler.

What is Scanbuild?

scan-build is a command line utility that enables a user to run the static analyzer over their codebase as part of performing a regular build (from the command line).

Is Clang-tidy a static analysis tool?

clang-tidy is a clang-based C++ “linter” tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis.


1 Answers

I found no documentation about this, so I dug around the clang source code.

It turns out that scan-build and ccc-analyzer (both perl scripts) don't output these error reports. Rather, the generation of the HTML reports is actually part of the clang compiler. The scan-build script simply ties together the various output files and adds a report index.

See

http://clang.llvm.org/doxygen/HTMLDiagnostics_8cpp_source.html

for the Clang source code.

To get clang to generate HTML reports for normal warnings/errors would require using the HTMLDiagnostics outside of the static analyzer. I know very little about Clang/LLVM internals, so I'm not sure how much effort this would require.

like image 189
Bobby Moretti Avatar answered Oct 01 '22 20:10

Bobby Moretti