[clang-tools-extra] Add --project-root to clangd (PR #155905)

Mythreya Kuricheti via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 28 23:38:52 PST 2025


MythreyaK wrote:

That sounds reasonable, thank you! 

Two more questions, 

> If you don't have a compile_commands.json file in your workspace's root directory

For the example I was suggesting, only the subprojects have the compilation database, but `--project-root` would point to the parent directory. My understanding is that a single index is generated across all subprojects, with their respective `compile_commands.json`, allowing for cross-referencing, which is really handy! 


> the new behaviour that clangd looks for such a file there even for files outside the workspace directory is basically a no-op. Clangd will continue using the sub-project compile_commands.json files based on ancestor-directory lookup just as it did before.

So as long as an open file is in one of these `compile_commands.json`, clangd will use that for indexing, correct? How will indexing for included files (from outside of the project) be handled? For example, one subproject's macros (say, `USE_WAYLAND` vs `USE_XCB`) could expose symbols differently when including a system header.  


https://github.com/llvm/llvm-project/pull/155905


More information about the cfe-commits mailing list