[clang] 398f253 - [clang][deps] Include "-cc1" in the arguments

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 22 01:58:01 PDT 2021


Author: Jan Svoboda
Date: 2021-04-22T10:57:56+02:00
New Revision: 398f25340000f26d648ebbc7eae9dc401ffc7d5f

URL: https://github.com/llvm/llvm-project/commit/398f25340000f26d648ebbc7eae9dc401ffc7d5f
DIFF: https://github.com/llvm/llvm-project/commit/398f25340000f26d648ebbc7eae9dc401ffc7d5f.diff

LOG: [clang][deps] Include "-cc1" in the arguments

To simplify tools consuming dependency scanning results, prepend the "-cc1" argument by default.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D100942

Added: 
    

Modified: 
    clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
    clang/test/ClangScanDeps/modules-full.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 68a03291e7bb..a1e54532f3e6 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -43,18 +43,13 @@ serializeCompilerInvocation(CompilerInvocation &CI) {
   llvm::BumpPtrAllocator Alloc;
   llvm::StringSaver Strings(Alloc);
   auto SA = [&Strings](const Twine &Arg) { return Strings.save(Arg).data(); };
-  SmallVector<const char *, 32> Args;
 
-  // Synthesize full command line from the CompilerInvocation.
+  // Synthesize full command line from the CompilerInvocation, including "-cc1".
+  SmallVector<const char *, 32> Args{"-cc1"};
   CI.generateCC1CommandLine(Args, SA);
 
   // Convert arguments to the return type.
-  std::vector<std::string> Ret;
-  Ret.reserve(Args.size());
-  for (const char *Arg : Args)
-    Ret.emplace_back(Arg);
-
-  return Ret;
+  return std::vector<std::string>{Args.begin(), Args.end()};
 }
 
 std::vector<std::string> ModuleDeps::getFullCommandLine(

diff  --git a/clang/test/ClangScanDeps/modules-full.cpp b/clang/test/ClangScanDeps/modules-full.cpp
index 4337ae9642a5..5c3e53610e5a 100644
--- a/clang/test/ClangScanDeps/modules-full.cpp
+++ b/clang/test/ClangScanDeps/modules-full.cpp
@@ -37,6 +37,7 @@
 // CHECK-NEXT:       ],
 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:       "command-line": [
+// CHECK-NEXT:         "-cc1",
 // CHECK:              "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
 // CHECK:              "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
 // CHECK-NOT:          "-fimplicit-module-maps",
@@ -53,6 +54,7 @@
 // CHECK-NEXT:       "clang-module-deps": [],
 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:       "command-line": [
+// CHECK-NEXT:         "-cc1",
 // CHECK-NOT:          "-fimplicit-module-maps",
 // CHECK:              "-fno-implicit-modules",
 // CHECK:            ],
@@ -67,6 +69,7 @@
 // CHECK-NEXT:       "clang-module-deps": [],
 // CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
 // CHECK-NEXT:       "command-line": [
+// CHECK-NEXT:         "-cc1",
 // CHECK-NOT:          "-fimplicit-module-maps",
 // CHECK:              "-fno-implicit-modules",
 // CHECK:            ],


        


More information about the cfe-commits mailing list