[clang-tools-extra] [clangd] fix wrong resouce-dir (PR #203332)
Aleksandr Platonov via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 06:09:49 PDT 2026
================
@@ -135,6 +135,25 @@ std::string detectStandardResourceDir() {
return GetResourcesPath("clangd", (void *)&StaticForMainAddr);
}
+std::optional<std::string>
+detectResourceDirWithClangPath(std::optional<std::string> ClangPath) {
+ std::string ResourceDir = detectStandardResourceDir();
+ if (llvm::sys::fs::exists(ResourceDir)) {
+ return ResourceDir;
+ }
+ log("Detect default -resource-dir={0} not valid", ResourceDir);
+
+ if (ClangPath.has_value()) {
+ ResourceDir = GetResourcesPath(*ClangPath);
+ if (llvm::sys::fs::exists(ResourceDir)) {
+ return ResourceDir;
+ }
+ log("Detect default -resource-dir={0} not valid", ResourceDir);
+ }
+
+ return std::nullopt;
----------------
ArcsinX wrote:
Here we have 2 identical messages, but I think we need to make it clear the origin.
Also, maybe these messages should come into verbose log (vlog instead of log) and if at the end we can't find resource directory, we can write a message with elog, which suggestion to specify -resource-dir via clangd command line arguments
Something like this:
vlog("Auto-detected standard resource directory '{0}' doesn't exist", ResourceDir);
...
vlog("Auto-detected using clang path '{0}' resource directory '{1}' doesn't exist", *ClangPath, ResourceDir);
...
elog("Failed to auto-detect resource directory, specify it manually via --resource-dir command line argument");
https://github.com/llvm/llvm-project/pull/203332
More information about the cfe-commits
mailing list