我要评分
获取效率
正确性
完整性
易理解

Obtaining compile_commands.json

For a project built by CMake, you can add the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON option to the CMake command to generate the compile_commands.json file in the build directory.

Description of escape characters in compile_commands.json:

If some escape characters in the compile_commands.json file cannot be used, this scenario is not supported.

Another solution is as follows:

For example, -D__FILE__=\\\"test.cpp\\\" in a source code build command corresponds to -D__FILE__=\"test.cpp\" in a shell command.

In this scenario, the source code probability shall be annotated in the -r ***.profdata format. In addition, you need to modify the compile_commands.json content by replacing \\\ with \. The corresponding vim command is %s/\\\\//g