clanganalyzer
clanganalyzer runs the Clang static analyzer against a project using its compilation database, and generates a report of the potential bugs it finds. It lets you analyze an existing code base without modifying the build.
How to use
A typical workflow with a CMake project:
$ cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON $ clanganalyzer --cdb build/compile_commands.json --output report
This runs the analyzer against every entry of the compilation database and writes an HTML report into a subdirectory of the output directory. By default the compilation database is read from compile_commands.json in the current directory, and reports are written under the system temp directory.
Some commonly used options:
--output <path> — where to put the analyzer reports.
--status-bugs — exit with a non-zero status if potential bugs were found; useful in CI.
--exclude <directory> — skip files in the given directory (e.g. third-party code); can be repeated.
--plist, --plist-html — emit machine-readable plist output instead of (or along with) HTML.
Use --help for the full list of options. The tool is also installed under the alias analyze-build, the name it had in earlier releases.
How to install
The package is published on PyPI as scan-build for historical reasons (see History). Install it with pip:
$ pip install scan-build
Or as a standalone tool with uv:
$ uv tool install scan-build
Prerequisites and limitations
To run the analysis you need:
clang, to compile the sources and to run the static analyzer.
A compilation database (compile_commands.json) for your project. CMake can generate one with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON; for other build systems, use Bear.
The tool itself requires a Python interpreter (version 3.10 or later). It has been tested on FreeBSD, GNU/Linux, macOS and Windows.
Unlike earlier versions, this package does not intercept build commands: if your build system cannot export a compilation database, create one with Bear before running the analysis.
Problem reports
If you find a bug in the program or in this documentation, or would like to propose an improvement, please use the project’s issue tracker. Please describe the bug and where you found it. If you have a suggestion how to fix it, include that as well. Patches are also welcome.
Development
To set up a development environment:
$ git clone https://github.com/rizsotto/scan-build.git $ cd scan-build $ uv sync
To run tests:
$ uv run pytest tests/unit $ uv run lit -v tests/functional
To run formatting, linting and type checking:
$ uv run ruff check . $ uv run ruff format . $ uv run ty check clanganalyzer
History
This project started as a Python rewrite of the scan-build Perl scripts shipped with Clang. An earlier version was contributed to the Clang repository as scan-build-py, and this project has been published on PyPI under the name scan-build ever since — which is why the package name and the command name differ.
Up to version 2.x the package also provided intercept-build, a tool to capture compiler calls and produce a compilation database. That functionality was removed in version 3.0: the Bear project now covers all targeted platforms (including Windows, which was the original reason for the Python implementation), so this package focuses solely on running the analyzer.
License
The project is licensed under the MIT License. See LICENSE.txt for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scan_build-3.1.0.tar.gz.
File metadata
- Download URL: scan_build-3.1.0.tar.gz
- Upload date:
- Size: 45.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc98511d2c3acf306a11f0b3b580e04c13a936449da73576c8f623ae514d6bb6
|
|
| MD5 |
76b70553fd933f0eb7fbaf6fce6abd3d
|
|
| BLAKE2b-256 |
461776f65ac070aa9fbdf6c1982dc02395f03aac887dd1924aff12336b396f58
|
Provenance
The following attestation bundles were made for scan_build-3.1.0.tar.gz:
Publisher:
python-publish.yml on rizsotto/scan-build
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scan_build-3.1.0.tar.gz -
Subject digest:
dc98511d2c3acf306a11f0b3b580e04c13a936449da73576c8f623ae514d6bb6 - Sigstore transparency entry: 2407843312
- Sigstore integration time:
-
Permalink:
rizsotto/scan-build@0ed82528f35d651c1b2d53d13759410116a9f77f -
Branch / Tag:
refs/tags/3.1.0 - Owner: https://github.com/rizsotto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0ed82528f35d651c1b2d53d13759410116a9f77f -
Trigger Event:
release
-
Statement type:
File details
Details for the file scan_build-3.1.0-py3-none-any.whl.
File metadata
- Download URL: scan_build-3.1.0-py3-none-any.whl
- Upload date:
- Size: 33.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a8910d1efffa67c23ca4fd677b2046544f03928aa0c328f8e86ec83beacec0b
|
|
| MD5 |
7e6ed8e2cb7501997466e7fe34507127
|
|
| BLAKE2b-256 |
3d73ab7bb361313d112e99f0bdf72798205790f33b2fd85aa352ea02746c9206
|
Provenance
The following attestation bundles were made for scan_build-3.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on rizsotto/scan-build
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scan_build-3.1.0-py3-none-any.whl -
Subject digest:
4a8910d1efffa67c23ca4fd677b2046544f03928aa0c328f8e86ec83beacec0b - Sigstore transparency entry: 2407843335
- Sigstore integration time:
-
Permalink:
rizsotto/scan-build@0ed82528f35d651c1b2d53d13759410116a9f77f -
Branch / Tag:
refs/tags/3.1.0 - Owner: https://github.com/rizsotto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0ed82528f35d651c1b2d53d13759410116a9f77f -
Trigger Event:
release
-
Statement type: