CodeChecker: running the analyzer from the command line
+ +Basic Usage
+ ++Install CodeChecker as described here: CodeChecker Install Guide. +
+ ++Create a compilation database. If you use cmake then pass the -DCMAKE_EXPORT_COMPILE_COMMANDS=1 parameter to cmake. Cmake will create a compile_commands.json file. +If you have a Makefile based or similar build system then you can log the build commands with the help of CodeChecker: +
+make clean +CodeChecker log -b "make" -o compile_commands.json ++ + +
+Analyze your project. +
+CodeChecker analyze compile_commands.json -o ./reports ++ + +
+View the analysis results. +Print the detailed results in the command line: +
+CodeChecker parse --print-steps ./reports ++Or view the detailed results in a browser: +
+CodeChecker parse ./reports -e html -o ./reports_html +firefox ./reports_html/index.html ++ + +
+Optional: store the analysis results in a DB. +
+mkdir ./ws +CodeChecker server -w ./ws -v 8555 & +CodeChecker store ./reports --name my-project --url http://localhost:8555/Default ++ + +
+Optional: manage (categorize, suppress) the results in your web browser: +
+firefox http://localhost:8555/Default ++ + +
Detailed Usage
+ ++For extended documentation please refer to the official site of CodeChecker! +
diff --git a/clang/www/analyzer/command-line.html b/clang/www/analyzer/command-line.html new file mode 100644 --- /dev/null +++ b/clang/www/analyzer/command-line.html @@ -0,0 +1,67 @@ + + + +Running the analyzer from the command line
+ +Static Analyzer is by design a GUI tool. Its purpose is to find buggy execution +paths in the program, and such paths are very hard to comprehend by looking at +a non-interactive standard output. It is possible, however, to invoke the +Static Analyzer from the command line in order to obtain analysis results, and +then later view them interactively in a graphical interface. The following +tools are used commonly to run the analyzer from the command line. Both tools +are wrapper scripts to drive the analysis and the underlying invocations of the +Clang compiler: +
-
+
- Scan-Build + is an old and simple command-line tool that emits static analyzer warnings as HTML files while compiling your project. You can view the analysis results in your web browser. + +
- + Useful for individual developers who simply want to view static analysis results at their desk, or in a very simple collaborative environment. + +
- + Works on all major platforms (Windows, Linux, macOS) and is available as a package in many Linux distributions. + +
- + Does not include support for cross-translation-unit analysis. + +
- CodeChecker + is a web server that runs the Static Analyzer on your projects on demand and maintains a database of issues. + +
- + Perfect for managing large amounts of Static Analyzer warnings in a collaborative environment. + +
- + Generally much more feature-rich than scan-build. + +
- Supports incremental analysis: Results can be stored in a database, subsequent analysis runs can be compared to list the newly added defects. +
- Cross Translation Unit (CTU) analysis is supported fully on Linux via CodeChecker. +
- Can run clang-tidy checkers too. +
- Open source, but out-of-tree, i.e. not part of the LLVM project. +
-
+
-
+
+
++
+ +The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs.
-Currently it can be run either as a standalone -tool or within Xcode. The standalone tool is -invoked from the command line, and is intended to be run in tandem with a build +
Currently it can be run either from the command + line or if you use macOS then within Xcode. When +invoked from the command line, it is intended to be run in tandem with a build of a codebase.