Source Code Annotation Using clang-prob-annotate
- Annotation method 1
Command: clang-prob-annotate <Source file to be annotated> <Configuration option> -- Original build command of the source file -fprofile-instr-use=/path/to/profdata
The reason for using the original build command of the source file is as follows: When the tool parses the source file, some macro-controlled content may be inconsistent with the original preprocessing content. Incorrect behavior may cause unexpected errors. Strictly follow the guide. This method applies only to a single source file.
- Annotation method 2
Use compile_commands.json to transfer the build command of the source file. (Note: This method does not support the scenario where the build command contains special escape characters.)
Dependency: Modify the cmake option or CMakeLists.txt file of the project, add the compilation option -fprofile-instr-use=/path/to/***.profdata to the entire project, and run the cmake command (instead of the make command) again in the build directory to generate the updated the compile_commands.json file.
Command: clang-prob-annotate <Source file to be annotated> -p="/path/to/compile_commands.json"
Note: You can run the clang-prob-annotate -h/--help command to view the supported configuration options.
