HighCommander4 wrote:

> If you don't have a `compile_commands.json` file in your workspace's root 
> directory, 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.

I guess in retrospect this is not an obvious choice, e.g. it's not how 
`--compile-commands-dir` works (if you specify 
`--compile-commands-dir=<workspace_root>` but your `compile_commands.json` 
files are actually in subdirectories, clangd won't use those even for source 
file inside the subdirectories).

So we could say `--strong-workspace-mode`'s behaviours are a strict superset of 
`--compile-commands-dir=<workspace_root>`, and in that case the guidance would 
be "don't use strong workspace mode for projects of the sort you describe".

But I think it would more user-friendly for strong workspace mode to use 
`<workspace_root>/compile_commands.json` _if it exists_ and fall back to 
ancestor-directory lookup otherwise. This would make it usable with a wider 
variety of workflows (and maybe even leave room for someday making it the 
default for some editors like vscode).

https://github.com/llvm/llvm-project/pull/155905
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to