9.3 Clang tools and a CDB
The concept of a CDB is not specific to Clang but Clang-based tools make extensive use of it. For instance, the Clang compiler itself can use a compilation database to understand how to compile files in a project. Tools such as Clang-Tidy and Clangd (for language support in IDEs) can also use it to ensure they understand code as it was built, making their analyses and transformations more accurate.
Clang-Tidy Configuration for Large Projects
To use clang-tidy with a CDB, you typically don’t need any additional configuration. Clang-tidy can automatically detect and utilize the compile
_commands.json
file in your project’s root directory.
On the other hand, Clang Tools provide a special option, -p, defined as follows:
-p <build-path> is used to read a compile command database
You can use this option to run Clang-Tidy on a file from the Clang source code. For example, if you run it from the llvm-project...