sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang-tools-extra.

This is a clever cross-cutting sanity test for clang's arg parsing I suppose.
But clangd creates thousands of invocations, ~all with identical trivial
arguments, and problems with these would be caught by clang's tests.
This overhead accounts for 10% of total unittest time!


Repository:
  rG LLVM Github Monorepo

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,17 @@
 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);
+  ArgStrs.push_back(Argv.front().c_str());
+  // 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.push_back("-Xclang=-no-round-trip-args");
+  for (const auto &S : Argv.drop_front())
     ArgStrs.push_back(S.c_str());
 
   CreateInvocationOptions CIOpts;


Index: clang-tools-extra/clangd/Compiler.cpp
===================================================================
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,10 +85,17 @@
 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);
+  ArgStrs.push_back(Argv.front().c_str());
+  // 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.push_back("-Xclang=-no-round-trip-args");
+  for (const auto &S : Argv.drop_front())
     ArgStrs.push_back(S.c_str());
 
   CreateInvocationOptions CIOpts;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to