Skip to content

Commit 82e5275

Browse files
committed
[clang][modules] Strip LLVM options (llvm#75405)
Currently, the dep scanner does not remove LLVM options from the argument list. Since LLVM options shouldn't affect the AST, it is safe to remove them all. (cherry picked from commit e007551) Conflicts: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
1 parent e79a45b commit 82e5275

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
128128
CI.getFrontendOpts().OutputFile = "-";
129129
// FIXME: a build system may want to provide a new path.
130130
CI.getFrontendOpts().IndexUnitOutputPath.clear();
131+
// LLVM options are not going to affect the AST
132+
CI.getFrontendOpts().LLVMArgs.clear();
131133

132134
// TODO: Figure out better way to set options to their default value.
133135
CI.getCodeGenOpts().MainFileName.clear();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: rm -rf %t
2+
// RUN: split-file %s %t
3+
// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
4+
5+
// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full > %t/result1.txt
6+
// RUN: FileCheck %s -input-file %t/result1.txt
7+
8+
// CHECK: "modules": [
9+
// CHECK-NEXT: {
10+
// CHECK: "command-line": [
11+
// CHECK-NOT: "-mllvm"
12+
// CHECK: ]
13+
// CHECK: "name": "A"
14+
// CHECK: }
15+
// CHECK-NOT: "name": "A"
16+
// CHECK: "translation-units"
17+
18+
//--- cdb1.json.template
19+
[
20+
{
21+
"directory": "DIR",
22+
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -fsyntax-only DIR/t1.m",
23+
"file": "DIR/t1.m"
24+
},
25+
{
26+
"directory": "DIR",
27+
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -mllvm -stackmap-version=2 -fsyntax-only DIR/t2.m",
28+
"file": "DIR/t2.m"
29+
}
30+
]
31+
32+
//--- modules/A/module.modulemap
33+
34+
module A {
35+
umbrella header "A.h"
36+
}
37+
38+
//--- modules/A/A.h
39+
40+
typedef int A_t;
41+
42+
//--- t1.m
43+
@import A;
44+
45+
//--- t2.m
46+
@import A;

0 commit comments

Comments
 (0)