[PATCH] D125169: [clangd] Skip extra round-trip in parsing args in debug builds. NFC

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 9 05:46:47 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb53eb1ef436: [clangd] Skip extra round-trip in parsing args in debug builds. NFC (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D125169?vs=427869&id=428047#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125169/new/

https://reviews.llvm.org/D125169

Files:
  clang-tools-extra/clangd/Compiler.cpp


Index: clang-tools-extra/clangd/Compiler.cpp
===================================================================
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,10 +85,16 @@
 std::unique_ptr<CompilerInvocation>
 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
                         std::vector<std::string> *CC1Args) {
-  if (Inputs.CompileCommand.CommandLine.empty())
+  llvm::ArrayRef<std::string> Argv = Inputs.CompileCommand.CommandLine;
+  if (Argv.empty())
     return nullptr;
   std::vector<const char *> ArgStrs;
-  for (const auto &S : Inputs.CompileCommand.CommandLine)
+  ArgStrs.reserve(Argv.size() + 1);
+  // In asserts builds, CompilerInvocation redundantly reads/parses cc1 args as
+  // a sanity test. This is not useful to clangd, and costs 10% of test time.
+  // To avoid mismatches between assert/production builds, disable it always.
+  ArgStrs = {Argv.front().c_str(), "-Xclang", "-no-round-trip-args"};
+  for (const auto &S : Argv.drop_front())
     ArgStrs.push_back(S.c_str());
 
   CreateInvocationOptions CIOpts;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125169.428047.patch
Type: text/x-patch
Size: 1122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220509/337d14c7/attachment.bin>


More information about the cfe-commits mailing list