Skip to content

Commit b05c4d3

Browse files
committed
[Clang][ScanDeps] Actually pass the non path command line modifications.
1 parent 5286f37 commit b05c4d3

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ DependencyScanningTool::getFullDependencies(
128128
if (MD.ImportedByMainFile)
129129
FD.ClangModuleDeps.push_back({MD.ModuleName, ContextHash});
130130
}
131+
132+
FD.AdditionalNonPathCommandLine = {
133+
"-fno-implicit-modules",
134+
"-fno-implicit-module-maps",
135+
};
131136

132137
FullDependenciesResult FDR;
133138

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ void dependencies::detail::appendCommonModuleArguments(
5353
}
5454
};
5555

56-
Result.push_back("-fno-implicit-modules");
57-
Result.push_back("-fno-implicit-module-maps");
5856
AddArgs(Modules);
5957
}
6058

@@ -159,6 +157,10 @@ void ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
159157
*MF, true, true, [&](const serialization::InputFile &IF, bool isSystem) {
160158
MD.FileDeps.insert(IF.getFile()->getName());
161159
});
160+
MD.NonPathCommandLine = {
161+
"-remove-preceeding-explicit-module-build-incompatible-options",
162+
"-fno-implicit-modules", "-emit-module", "-fmodule-name=" + MD.ModuleName,
163+
};
162164

163165
llvm::DenseSet<const Module *> AddedModules;
164166
addAllSubmoduleDeps(M, MD, AddedModules);

clang/test/ClangScanDeps/modules-full.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
// CHECK-NEXT: ],
3232
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
3333
// CHECK-NEXT: "command-line": [
34+
// CHECK-NEXT: "-remove-preceeding-explicit-module-build-incompatible-options",
3435
// CHECK-NEXT: "-fno-implicit-modules",
35-
// CHECK-NEXT: "-fno-implicit-module-maps",
36+
// CHECK-NEXT: "-emit-module",
37+
// CHECK-NEXT: "-fmodule-name=header1",
3638
// CHECK-NEXT: "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
3739
// CHECK-NEXT: "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
3840
// CHECK-NEXT: ],
@@ -47,8 +49,10 @@
4749
// CHECK-NEXT: "clang-module-deps": [],
4850
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
4951
// CHECK-NEXT: "command-line": [
52+
// CHECK-NEXT: "-remove-preceeding-explicit-module-build-incompatible-options",
5053
// CHECK-NEXT: "-fno-implicit-modules",
51-
// CHECK-NEXT: "-fno-implicit-module-maps"
54+
// CHECK-NEXT: "-emit-module",
55+
// CHECK-NEXT: "-fmodule-name=header1"
5256
// CHECK-NEXT: ],
5357
// CHECK-NEXT: "context-hash": "[[CONTEXT_HASH_H2:[A-Z0-9]+]]",
5458
// CHECK-NEXT: "file-deps": [
@@ -61,8 +65,10 @@
6165
// CHECK-NEXT: "clang-module-deps": [],
6266
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/Inputs/module.modulemap",
6367
// CHECK-NEXT: "command-line": [
68+
// CHECK-NEXT: "-remove-preceeding-explicit-module-build-incompatible-options",
6469
// CHECK-NEXT: "-fno-implicit-modules",
65-
// CHECK-NEXT: "-fno-implicit-module-maps"
70+
// CHECK-NEXT: "-emit-module",
71+
// CHECK-NEXT: "-fmodule-name=header2"
6672
// CHECK-NEXT: ],
6773
// CHECK-NEXT: "context-hash": "[[CONTEXT_HASH_H1]]",
6874
// CHECK-NEXT: "file-deps": [

clang/test/Index/Core/scan-deps.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
// CHECK-NEXT: [[PREFIX]]/Inputs/module/SubModA.h
2020
// CHECK-NEXT: [[PREFIX]]/Inputs/module/SubSubModA.h
2121
// CHECK-NEXT: [[PREFIX]]/Inputs/module/module.modulemap
22-
// CHECK-NEXT: build-args:
22+
// CHECK-NEXT: build-args: -remove-preceeding-explicit-module-build-incompatible-options -fno-implicit-modules -emit-module -fmodule-name=ModA
2323
// CHECK-NEXT: dependencies:
2424
// CHECK-NEXT: context-hash: [[CONTEXT_HASH]]
2525
// CHECK-NEXT: module-deps:
2626
// CHECK-NEXT: ModA:[[CONTEXT_HASH]]
2727
// CHECK-NEXT: file-deps:
2828
// CHECK-NEXT: [[PREFIX]]/scan-deps.m
29-
// CHECK-NEXT: additional-build-args:
29+
// CHECK-NEXT: additional-build-args: -fno-implicit-modules -fno-implicit-module-maps

clang/tools/libclang/CDependencies.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ class FullDependencyConsumer : public DependencyConsumer {
121121
FD.ClangModuleDeps.push_back({MD.ModuleName, ContextHash});
122122
}
123123

124+
FD.AdditionalNonPathCommandLine = {
125+
"-fno-implicit-modules",
126+
"-fno-implicit-module-maps",
127+
};
128+
124129
FullDependenciesResult FDR;
125130

126131
for (auto &&M : ClangModuleDeps) {
@@ -178,7 +183,7 @@ static CXFileDependencies *getFullDependencies(
178183
for (const ClangModuleDep &CMD : MD.ClangModuleDeps)
179184
Modules.push_back(CMD.ModuleName + ":" + CMD.ContextHash);
180185
M.ModuleDeps = cxstring::createSet(Modules);
181-
M.BuildArguments = cxstring::createSet(std::vector<std::string>{});
186+
M.BuildArguments = cxstring::createSet(MD.NonPathCommandLine);
182187
}
183188
MDC(Context, MDS);
184189
}
@@ -191,7 +196,8 @@ static CXFileDependencies *getFullDependencies(
191196
for (const ClangModuleDep &CMD : FD.ClangModuleDeps)
192197
Modules.push_back(CMD.ModuleName + ":" + CMD.ContextHash);
193198
FDeps->ModuleDeps = cxstring::createSet(Modules);
194-
FDeps->AdditionalArguments = cxstring::createSet(std::vector<std::string>{});
199+
FDeps->AdditionalArguments =
200+
cxstring::createSet(FD.AdditionalNonPathCommandLine);
195201
return FDeps;
196202
}
197203

0 commit comments

Comments
 (0)