[PATCH] D54872: [clangd] Add ability to not use -resource-dir at all

Marc-Andre Laperle via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 24 20:30:53 PST 2018


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 <malaperle at gmail.com>


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);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54872.175168.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181125/28cbe6c3/attachment.bin>


More information about the cfe-commits mailing list