Linux command
scan-build 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Analyze build
scan-build make
Analyze with output directory
scan-build -o [reports/] make
Use specific checkers
scan-build -enable-checker [alpha.security] make
Open results in browser
scan-build --view make
With CMake
scan-build cmake --build [build/]
List available checkers
scan-build --list-checkers
Verbose output
scan-build -v make
说明
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.
参数
- -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.
FAQ
What is the scan-build command used for?
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.
How do I run a basic scan-build example?
Run `scan-build make` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -o _DIR_ do in scan-build?
Output directory.