Skip to content

Commit 21c4c10

Browse files
committed
[Clang][ScanDeps] Ignore __inferred_module.map dependency.
This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency.
1 parent 0672a6a commit 21c4c10

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ void ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
155155
MDC.Instance.getASTReader()->getModuleManager().lookup(M->getASTFile());
156156
MDC.Instance.getASTReader()->visitInputFiles(
157157
*MF, true, true, [&](const serialization::InputFile &IF, bool isSystem) {
158+
// __inferred_module.map is the result of the way in which an implicit
159+
// module build handles inferred modules. It adds an overlay VFS with
160+
// this file in the proper directory and relies on the rest of Clang to
161+
// handle it like normal. With explicitly built modules we don't need
162+
// to play VFS tricks, so replace it with the correct module map.
163+
if (IF.getFile()->getName().endswith("__inferred_module.map")) {
164+
MD.FileDeps.insert(ModuleMap->getName());
165+
return;
166+
}
158167
MD.FileDeps.insert(IF.getFile()->getName());
159168
});
160169
MD.NonPathCommandLine = {

clang/test/ClangScanDeps/modules-inferred.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// CHECK-NEXT: "file-deps": [
3333
// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h",
3434
// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Headers/Inferred.h",
35-
// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/__inferred_module.map"
35+
// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
3636
// CHECK-NEXT: ],
3737
// CHECK-NEXT: "name": "Inferred"
3838
// CHECK-NEXT: }

0 commit comments

Comments
 (0)