scan-build
Clang static analyzer build integration tool
TLDR
Analyze build
SYNOPSIS
scan-build [-o dir] [--view] [options] build-command
DESCRIPTION
scan-build wraps build commands to run Clang's static analyzer on each compiled source file. It intercepts compilation, analyzing C, C++, and Objective-C code for bugs including null pointer dereferences, memory leaks, use-after-free errors, and API misuse without executing the code.
Analysis results are presented as HTML reports with interactive path visualizations showing the exact sequence of events leading to each bug. Additional checker categories can be enabled with -enable-checker for deeper analysis including security vulnerabilities and experimental checks. The --status-bugs flag returns a non-zero exit code when bugs are found, useful for CI integration.
PARAMETERS
-o DIR
Output directory.--view
Open results in browser.-v
Verbose output.-enable-checker CHECKER
Enable checker.-disable-checker CHECKER
Disable checker.--list-checkers
Show available checkers.--status-bugs
Exit non-zero if bugs found.-plist
Generate plist files.
CAVEATS
Increases build time significantly. False positives require tuning. C/C++ and Objective-C only.
HISTORY
scan-build is part of the Clang project. It provides an accessible interface to Clang's static analysis capabilities.
