[clang-tools-extra] [clangd] fix wrong resouce-dir (PR #203332)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 13 09:40:35 PDT 2026


HighCommander4 wrote:

> clangd may be need a mechanism to check `resource-dir` , and give user suggestion to set it , if something wrong.
> 
> Do you have any suggestion?

Ok, so clangd could check if the resource directory which is auto-detected exists, and if it's not then notify the user that they should use the `-resource-dir` option to point to the correct one.

In terms of how to notify the user, I can think of 3 options:

 1. Print an error message to the log (clangd's stderr) using `elog()`. This is the easiest to implement, but it's  also easy for the user to overlook it.
 
 2. Generate a diagnostic, pushed to the client with `textDocument/publishDiagnostics`, on line 1 of any opened file. This takes some more plumbing to implement, but it's much more likely the user will notice it.

 3. Exit clangd, i.e. clangd refuses to start with a non-existent resource directory. This one the user definitely can't miss, but it's a pretty drastic option. (Maybe there are use cases where clangd still works without a resource directory, which this would break?)

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


More information about the cfe-commits mailing list