Skip to content

Commit c3b4558

Browse files
committed
switch the order CodeChecker and scan-build
1 parent 151c674 commit c3b4558

File tree

1 file changed

+52
-51
lines changed

1 file changed

+52
-51
lines changed

clang/docs/analyzer/user-docs/CommandLineUsage.rst

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Command Line Usage: CodeChecker and scan-build
2-
===============================================
1+
Command Line Usage: scan-build and CodeChecker
2+
==============================================
33

44
This document provides guidelines for running Clang Static Analyzer from the command line on whole projects.
55
CodeChecker and scan-build are two CLI tools for using CSA on multiple files (tranlation units).
@@ -16,62 +16,19 @@ It is possible, however, to invoke the Static Analyzer from the command line in
1616
The following tools are used commonly to run the analyzer from the command line.
1717
Both tools are wrapper scripts to drive the analysis and the underlying invocations of the Clang compiler:
1818

19-
1. CodeChecker_ is a driver and web server that runs the Static Analyzer on your projects on demand and maintains a database of issues.
19+
1. 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.
20+
- Useful for individual developers who simply want to view static analysis results at their desk, or in a very simple collaborative environment.
21+
- Works on all major platforms (Windows, Linux, macOS) and is available as a package in many Linux distributions.
22+
- Does not include support for cross-translation-unit analysis.
23+
24+
2. CodeChecker_ is a driver and web server that runs the Static Analyzer on your projects on demand and maintains a database of issues.
2025
- Perfect for managing large amounts of Static Analyzer warnings in a collaborative environment.
2126
- Generally much more feature-rich than scan-build.
2227
- Supports incremental analysis: Results can be stored in a database, subsequent analysis runs can be compared to list the newly added defects.
2328
- :doc:`CrossTranslationUnit` is supported fully on Linux via CodeChecker.
2429
- Can run clang-tidy checkers too.
2530
- Open source, but out-of-tree, i.e. not part of the LLVM project.
2631

27-
2. 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.
28-
- Useful for individual developers who simply want to view static analysis results at their desk, or in a very simple collaborative environment.
29-
- Works on all major platforms (Windows, Linux, macOS) and is available as a package in many Linux distributions.
30-
- Does not include support for cross-translation-unit analysis.
31-
32-
CodeChecker
33-
-----------
34-
35-
Basic Usage
36-
~~~~~~~~~~~
37-
38-
Install CodeChecker as described here: `CodeChecker Install Guide <https://github.com/Ericsson/codechecker/#Install-guide>`_.
39-
40-
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.
41-
If you have a Makefile based or similar build system then you can log the build commands with the help of CodeChecker::
42-
43-
make clean
44-
CodeChecker log -b "make" -o compile_commands.json
45-
46-
Analyze your project::
47-
48-
CodeChecker analyze compile_commands.json -o ./reports
49-
50-
View the analysis results.
51-
Print the detailed results in the command line::
52-
53-
CodeChecker parse --print-steps ./reports
54-
55-
Or view the detailed results in a browser::
56-
57-
CodeChecker parse ./reports -e html -o ./reports_html
58-
firefox ./reports_html/index.html
59-
60-
Optional: store the analysis results in a DB::
61-
62-
mkdir ./ws
63-
CodeChecker server -w ./ws -v 8555 &
64-
CodeChecker store ./reports --name my-project --url http://localhost:8555/Default
65-
66-
Optional: manage (categorize, suppress) the results in your web browser::
67-
68-
firefox http://localhost:8555/Default
69-
70-
Detailed Usage
71-
~~~~~~~~~~~~~~
72-
73-
For extended documentation please refer to the `official site of CodeChecker <https://github.com/Ericsson/codechecker/blob/master/docs/usage.md>`_!
74-
7532
scan-build
7633
----------
7734

@@ -236,3 +193,47 @@ When compiling your application to run on the simulator, it is important that **
236193
**scan-build** provides the ``--use-cc`` and ``--use-c++`` options to hardwire which compiler scan-build should use for building your code. Note that although you are chiefly interested in analyzing your project, keep in mind that running the analyzer is intimately tied to the build, and not being able to compile your code means it won't get fully analyzed (if at all).
237194

238195
If you aren't certain which compiler Xcode uses to build your project, try just running ``xcodebuild`` (without **scan-build**). You should see the full path to the compiler that Xcode is using, and use that as an argument to ``--use-cc``.
196+
197+
CodeChecker
198+
-----------
199+
200+
Basic Usage
201+
~~~~~~~~~~~
202+
203+
Install CodeChecker as described here: `CodeChecker Install Guide <https://github.com/Ericsson/codechecker/#Install-guide>`_.
204+
205+
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.
206+
If you have a Makefile based or similar build system then you can log the build commands with the help of CodeChecker::
207+
208+
make clean
209+
CodeChecker log -b "make" -o compile_commands.json
210+
211+
Analyze your project::
212+
213+
CodeChecker analyze compile_commands.json -o ./reports
214+
215+
View the analysis results.
216+
Print the detailed results in the command line::
217+
218+
CodeChecker parse --print-steps ./reports
219+
220+
Or view the detailed results in a browser::
221+
222+
CodeChecker parse ./reports -e html -o ./reports_html
223+
firefox ./reports_html/index.html
224+
225+
Optional: store the analysis results in a DB::
226+
227+
mkdir ./ws
228+
CodeChecker server -w ./ws -v 8555 &
229+
CodeChecker store ./reports --name my-project --url http://localhost:8555/Default
230+
231+
Optional: manage (categorize, suppress) the results in your web browser::
232+
233+
firefox http://localhost:8555/Default
234+
235+
Detailed Usage
236+
~~~~~~~~~~~~~~
237+
238+
For extended documentation please refer to the `official site of CodeChecker <https://github.com/Ericsson/codechecker/blob/master/docs/usage.md>`_!
239+

0 commit comments

Comments
 (0)