Skip to content

Commit ffa2a64

Browse files
committed
[Clang][DependencyScanner] Remove secondary actions from -cc1
The -arcmt-action= and -objcmt-migrate* actions were being passed to module builds. This caused these builds to fail, as they are secondary actions that suppress emitting modules. Differential Revision: https://reviews.llvm.org/D143040
1 parent 7e566a3 commit ffa2a64

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ ModuleDepCollector::makeInvocationForModuleBuildWithoutOutputs(
111111
CI.getDependencyOutputOpts().Targets.clear();
112112

113113
CI.getFrontendOpts().ProgramAction = frontend::GenerateModule;
114+
CI.getFrontendOpts().ARCMTAction = FrontendOptions::ARCMT_None;
115+
CI.getFrontendOpts().ObjCMTAction = FrontendOptions::ObjCMT_None;
116+
CI.getFrontendOpts().MTMigrateDir.clear();
114117
CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
115118
CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;
116119

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 -mode preprocess-dependency-directives > %t/result1.txt
6+
7+
// RUN: FileCheck %s -input-file %t/result1.txt
8+
9+
// Verify that secondary actions get stripped, and that there's a single version
10+
// of module A.
11+
12+
// CHECK: "modules": [
13+
// CHECK-NEXT: {
14+
// CHECK: "command-line": [
15+
// CHECK-NOT: "-arcmt-action=check"
16+
// CHECK-NOT: "-objcmt-migrate-literals"
17+
// CHECK-NOT: "-mt-migrate-directory"
18+
// CHECK: ]
19+
// CHECK: "name": "A"
20+
// CHECK: }
21+
// CHECK-NOT: "name": "A"
22+
// CHECK: "translation-units"
23+
24+
//--- cdb1.json.template
25+
[
26+
{
27+
"directory": "DIR",
28+
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-arcmt-check -fsyntax-only DIR/t1.m",
29+
"file": "DIR/t1.m"
30+
},
31+
{
32+
"directory": "DIR",
33+
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-objcmt-migrate bob -fsyntax-only DIR/t2.m",
34+
"file": "DIR/t2.m"
35+
}
36+
]
37+
38+
//--- modules/A/module.modulemap
39+
40+
module A {
41+
umbrella header "A.h"
42+
}
43+
44+
//--- modules/A/A.h
45+
46+
typedef int A_t;
47+
48+
//--- t1.m
49+
@import A;
50+
51+
//--- t2.m
52+
@import A;

0 commit comments

Comments
 (0)