Skip to content

Commit 46288ff

Browse files
committed
[clang][deps] Add module map describing compiled module to file dependencies.
When we add the module map describing the compiled module to the command line, add it to the file dependencies as well. Discovered while working on reproducers where a command line input was missing in the captured files as it wasn't considered a dependency.
1 parent f8e51df commit 46288ff

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,11 @@ void ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
444444
if (OptionalFileEntryRef CurrentModuleMap =
445445
PP.getHeaderSearchInfo()
446446
.getModuleMap()
447-
.getModuleMapFileForUniquing(CurrentModule))
447+
.getModuleMapFileForUniquing(CurrentModule)) {
448448
CI.getFrontendOpts().ModuleMapFiles.emplace_back(
449449
CurrentModuleMap->getNameAsRequested());
450+
Consumer.handleFileDependency(CurrentModuleMap->getNameAsRequested());
451+
}
450452

451453
SmallVector<ModuleID> DirectDeps;
452454
for (const auto &KV : ModularDeps)

clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
// CHECK: "file-deps": [
4747
// CHECK-NEXT: "[[PREFIX]]/modules-fmodule-name-no-module-built.m",
4848
// CHECK-NEXT: "[[PREFIX]]/Inputs/header3.h",
49-
// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h"
49+
// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
50+
// CHECK-NEXT: "Inputs/module.modulemap"
5051
// CHECK-NEXT: ],
5152
// CHECK-NEXT: "input-file": "[[PREFIX]]/modules-fmodule-name-no-module-built.m"
5253
// CHECK-NEXT: }

clang/test/ClangScanDeps/modules-header-sharing.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
// CHECK: ],
8080
// CHECK: "file-deps": [
8181
// CHECK-NEXT: "[[PREFIX]]/tu.m",
82-
// CHECK-NEXT: "[[PREFIX]]/shared/H.h"
82+
// CHECK-NEXT: "[[PREFIX]]/shared/H.h",
83+
// CHECK-NEXT: "[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
8384
// CHECK-NEXT: ],
8485
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
8586
// CHECK-NEXT: }

clang/test/ClangScanDeps/modules-implementation-module-map.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ framework module FWPrivate { header "private.h" }
2828
// CHECK: "-fmodule-name=FWPrivate",
2929
// CHECK: ],
3030
// CHECK: "file-deps": [
31-
// CHECK-NEXT: "[[PREFIX]]/tu.m"
31+
// CHECK-NEXT: "[[PREFIX]]/tu.m",
32+
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap"
3233
// CHECK-NEXT: ],
3334
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
3435
// CHECK-NEXT: }

clang/test/ClangScanDeps/modules-implementation-private.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
// CHECK: "file-deps": [
6666
// CHECK-NEXT: "[[PREFIX]]/tu.m",
6767
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Missed.h",
68-
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
68+
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
69+
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
6970
// CHECK-NEXT: ],
7071
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
7172
// CHECK-NEXT: }

0 commit comments

Comments
 (0)