malaperle created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay,
ioeric, ilya-biryukov.
Using Clang-cl, I have seen scenarios where the compilation database contains
all flags necessary to find compiler-specific (CL) headers, using /imsvc.
Specifying -resource-dir in this case is detrimental because it seems to have
priority over /imsvc flags. Currently in Clangd, the resource-dir is either
specified as a clangd argument (-resource-dir) or it falls back to
CompilerInvocation::GetResourcePath(). The -resource-dir argument cannot be set
to empty as it triggers the fall back.
This change allows -resource-dir= (nothing)
I'm not familiar enough with clang-cl to know whether or not specifying
-resource-dir is always wrong. If it is always, we could check for clang-cl and
not use the fallback ever but having the ability to nullify -resource-dir seems
useful anyway.
Signed-off-by: Marc-Andre Laperle <[email protected]>
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D54872
Files:
clangd/ClangdServer.cpp
clangd/tool/ClangdMain.cpp
Index: clangd/tool/ClangdMain.cpp
===================================================================
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -340,7 +340,7 @@
Opts.StorePreamblesInMemory = false;
break;
}
- if (!ResourceDir.empty())
+ if (ResourceDir.getNumOccurrences() > 0)
Opts.ResourceDir = ResourceDir;
Opts.BuildDynamicSymbolIndex = EnableIndex;
Opts.HeavyweightDynamicSymbolIndex = UseDex;
Index: clangd/ClangdServer.cpp
===================================================================
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -448,7 +448,8 @@
// Inject the resource dir.
// FIXME: Don't overwrite it if it's already there.
- C->CommandLine.push_back("-resource-dir=" + ResourceDir);
+ if (!ResourceDir.empty())
+ C->CommandLine.push_back("-resource-dir=" + ResourceDir);
return std::move(*C);
}
Index: clangd/tool/ClangdMain.cpp
===================================================================
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -340,7 +340,7 @@
Opts.StorePreamblesInMemory = false;
break;
}
- if (!ResourceDir.empty())
+ if (ResourceDir.getNumOccurrences() > 0)
Opts.ResourceDir = ResourceDir;
Opts.BuildDynamicSymbolIndex = EnableIndex;
Opts.HeavyweightDynamicSymbolIndex = UseDex;
Index: clangd/ClangdServer.cpp
===================================================================
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -448,7 +448,8 @@
// Inject the resource dir.
// FIXME: Don't overwrite it if it's already there.
- C->CommandLine.push_back("-resource-dir=" + ResourceDir);
+ if (!ResourceDir.empty())
+ C->CommandLine.push_back("-resource-dir=" + ResourceDir);
return std::move(*C);
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits