如何让Clang静态分析器将.plist文件生成到自定义目录?
Absolutely! You have a couple of straightforward ways to configure where the analyzer saves its .plist output files, depending on whether you're running the analyzer directly via clang or using the scan-build wrapper tool.
Using clang Directly
When invoking clang with static analysis enabled, you can use the -o flag to specify a custom path for the .plist file. Just include the full or relative path to your desired directory and filename.
Example command:
clang -analyze -o /path/to/your/custom/directory/analysis_results.plist your_source_file.c
This will generate the analysis report directly at the specified location instead of the current working directory.
Using scan-build (Recommended for Projects)
If you're using scan-build to run the analyzer across an entire project (e.g., with make or cmake), the -o flag works here too to set a custom output directory. scan-build will organize .plist files (along with HTML reports if enabled) in this location, usually under a timestamped subfolder to separate multiple runs.
Example command:
scan-build -o /path/to/your/custom/analysis_output make
Quick Tip
Make sure your target directory exists before running the analyzer—otherwise, you’ll get an error. Create it beforehand with:
mkdir -p /path/to/your/custom/directory
内容的提问来源于stack exchange,提问作者Hemant

