[clang-tools-extra] Add --project-root to clangd (PR #155905)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 29 21:00:38 PST 2025
HighCommander4 wrote:
> > the new behaviour that clangd looks for such a file there even for files outside the workspace directory is basically a no-op.
>
> Does this impact indexing files located outside of the projects but are `#include`ed in the project?
I think clangd today stores index data for such files in `$HOME/.cache/clangd/index`, which is not very intuitive in my opinion. With strong workspace mode, it would store them in `<workspace_root>/.cache/clangd/index`.
> > 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.
Other than the index storage location being `<workspace_root>/.cache/clangd/index`, I would expect it to work the same as it does today without strong workspace mode.
https://github.com/llvm/llvm-project/pull/155905
More information about the cfe-commits
mailing list