Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,13 @@ void ModuleDepCollectorPP::EndOfMainFile() {
for (StringRef VFS : MDC.ScanInstance.getHeaderSearchOpts().VFSOverlayFiles)
MDC.addFileDep(VFS);

if (Module *CurrentModule = PP.getCurrentModuleImplementation()) {
if (OptionalFileEntryRef CurrentModuleMap =
PP.getHeaderSearchInfo().getModuleMap().getModuleMapFileForUniquing(
CurrentModule))
MDC.addFileDep(CurrentModuleMap->getName());
}

for (const Module *M :
MDC.ScanInstance.getPreprocessor().getAffectingClangModules())
if (!MDC.isPrebuiltModule(M))
Expand Down
57 changes: 57 additions & 0 deletions clang/test/ClangScanDeps/modules-current-modulemap-file-dep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// RUN: rm -rf %t
// RUN: split-file %s %t

// RUN: sed -e "s|DIR|%/t|g" %t/vfs.yaml.in > %t/vfs.yaml

// RUN: clang-scan-deps -format experimental-full -j 1 -- \
// RUN: %clang -ivfsoverlay %t/vfs.yaml -fmodules -fimplicit-module-maps \
// RUN: -fmodules-cache-path=%t/cache -fmodule-name=ModuleName \
// RUN: -I %/t/remapped -c %t/header-impl.c -o %t/header-impl.o \
// RUN: | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t

// CHECK: "command-line": [
// CHECK: "-fmodule-map-file=[[PREFIX]]/remapped/module.modulemap"
// CHECK: "file-deps": [
// CHECK: "[[PREFIX]]/original/module.modulemap"

// Verify that "file-deps" references actual on-disk module map and not using the virtual path.

//--- vfs.yaml.in
{
"version": 0,
"case-sensitive": "false",
"roots": [
{
"name": "DIR/remapped",
"type": "directory",
"contents": [
{
"name": "module.modulemap",
"type": "file",
"external-contents": "DIR/original/module.modulemap"
},
{
"name": "header.h",
"type": "file",
"external-contents": "DIR/original/header.h"
}
]
}
]
}

//--- original/module.modulemap
module ModuleName {
header "header.h"
export *
}

//--- original/header.h
int foo_function(void);

//--- header-impl.c
#include <header.h>

int foo_function(void) {
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/modules-fmodule-name-no-module-built.m",
// CHECK-NEXT: "[[PREFIX]]/Inputs/header3.h",
// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h"
// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/modules-fmodule-name-no-module-built.m"
// CHECK-NEXT: }
3 changes: 2 additions & 1 deletion clang/test/ClangScanDeps/modules-header-sharing.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.m",
// CHECK-NEXT: "[[PREFIX]]/shared/H.h",
// CHECK-NEXT: "[[PREFIX]]/overlay.json"
// CHECK-NEXT: "[[PREFIX]]/overlay.json",
// CHECK-NEXT: "[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
// CHECK-NEXT: }
Expand Down
3 changes: 2 additions & 1 deletion clang/test/ClangScanDeps/modules-implementation-module-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ framework module FWPrivate { header "private.h" }
// CHECK: "-fmodule-name=FWPrivate",
// CHECK: ],
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.m"
// CHECK-NEXT: "[[PREFIX]]/tu.m",
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
// CHECK-NEXT: }
Expand Down
3 changes: 2 additions & 1 deletion clang/test/ClangScanDeps/modules-implementation-private.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
// CHECK: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/tu.m",
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Missed.h",
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.m"
// CHECK-NEXT: }
Expand Down