Skip to content

Commit 7606a69

Browse files
Merge pull request #82642 from cachemeifyoucan/eng/PR-153851818-release
2 parents a75f94e + bf32a8b commit 7606a69

File tree

2 files changed

+65
-5
lines changed

2 files changed

+65
-5
lines changed

lib/ClangImporter/ClangModuleDependencyScanner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
144144
if (!ctx.CASOpts.EnableCaching) {
145145
auto &overlayFiles = invocation.getMutHeaderSearchOpts().VFSOverlayFiles;
146146
for (auto overlay : overlayFiles) {
147+
if (llvm::is_contained(ctx.SearchPathOpts.VFSOverlayFiles, overlay))
148+
continue;
147149
swiftArgs.push_back("-vfsoverlay");
148150
swiftArgs.push_back(overlay);
149151
}
150-
// Clear overlay files since they are forwarded from swift to clang.
151-
overlayFiles.clear();
152152
}
153153

154154
// Add args reported by the scanner.

test/ScanDependencies/preserve_used_vfs.swift

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
// RUN: %empty-directory(%t)
33
// RUN: %empty-directory(%t/module-cache)
44
// RUN: %empty-directory(%t/inputs)
5+
// RUN: %empty-directory(%t/inputs-2)
56
// RUN: split-file %s %t
67

78
// RUN: sed -e "s|OUT_DIR|%t/redirects|g" -e "s|IN_DIR|%t/inputs|g" %t/overlay_template.yaml > %t/overlay.yaml
9+
// RUN: sed -e "s|OUT_DIR|%t/redirects-2|g" -e "s|IN_DIR|%t/inputs-2|g" %t/overlay_template_2.yaml > %t/overlay-2.yaml
810

9-
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-serialized -module-cache-path %t/module-cache %t/test.swift -o %t/deps.json -I %t/inputs -I %S/Inputs/Swift -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -Xcc -ivfsoverlay -Xcc %t/overlay.yaml
11+
/// Put some files in RealFileSystem that need to be over shadow by VFS.
12+
// RUN: touch %t/inputs/module.modulemap
13+
// RUN: touch %t/inputs-2/module.modulemap
14+
15+
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-serialized -module-cache-path %t/module-cache %t/test.swift -o %t/deps.json -I %t/inputs -I %t/inputs-2 -I %S/Inputs/Swift -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -Xcc -ivfsoverlay -Xcc %t/overlay.yaml -Xcc -ivfsoverlay -Xcc %t/overlay-2.yaml
1016
// RUN: %validate-json %t/deps.json | %FileCheck %s
1117

1218
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
@@ -15,6 +21,8 @@
1521
// RUN: %swift_frontend_plain @%t/swift.cmd
1622
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json SwiftOnoneSupport > %t/onone.cmd
1723
// RUN: %swift_frontend_plain @%t/onone.cmd
24+
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:Indirect > %t/Indirect.cmd
25+
// RUN: %swift_frontend_plain @%t/Indirect.cmd
1826
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json clang:F > %t/F.cmd
1927
// RUN: %swift_frontend_plain @%t/F.cmd
2028
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json F > %t/SwiftF.cmd
@@ -28,10 +36,11 @@
2836
// RUN: echo "\"-explicit-swift-module-map-file\"" >> %t/MyApp.cmd
2937
// RUN: echo "\"%t/map.json\"" >> %t/MyApp.cmd
3038

31-
// RUN: %target-swift-frontend @%t/MyApp.cmd %t/test.swift -Xcc -ivfsoverlay -Xcc %t/overlay.yaml \
39+
// RUN: %target-swift-frontend @%t/MyApp.cmd %t/test.swift -Xcc -ivfsoverlay -Xcc %t/overlay.yaml -Xcc -ivfsoverlay -Xcc %t/overlay-2.yaml \
3240
// RUN: -emit-module -o %t/Test.swiftmodule
3341

3442
//--- redirects/RedirectedF.h
43+
#include "Indirect_2.h"
3544
void funcRedirectedF(void);
3645

3746
//--- redirects/modulemap
@@ -40,6 +49,15 @@ module F {
4049
export *
4150
}
4251

52+
//--- redirects-2/RedirectedIndirect.h
53+
void funcRedirectedIndirect(void);
54+
55+
//--- redirects-2/modulemap
56+
module Indirect {
57+
header "Indirect_2.h"
58+
export *
59+
}
60+
4361
//--- overlay_template.yaml
4462
{
4563
'version': 0,
@@ -59,10 +77,30 @@ module F {
5977
]
6078
}
6179

80+
//--- overlay_template_2.yaml
81+
{
82+
'version': 0,
83+
'use-external-names': false,
84+
'roots': [
85+
{
86+
'name': 'IN_DIR', 'type': 'directory',
87+
'contents': [
88+
{ 'name': 'Indirect_2.h', 'type': 'file',
89+
'external-contents': 'OUT_DIR/RedirectedIndirect.h'
90+
},
91+
{ 'name': 'module.modulemap', 'type': 'file',
92+
'external-contents': 'OUT_DIR/modulemap'
93+
}
94+
]
95+
},
96+
]
97+
}
98+
6299
//--- test.swift
63100
import F
64101

65102
func testF() { funcRedirectedF() }
103+
func testIndirect() { funcRedirectedIndirect() }
66104

67105
// CHECK: "mainModuleName": "deps"
68106
/// --------Main module
@@ -94,11 +132,33 @@ func testF() { funcRedirectedF() }
94132
// CHECK: "-ivfsoverlay",
95133
// CHECK-NEXT: "-Xcc",
96134
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay.yaml",
135+
// CHECK-NEXT: "-Xcc",
136+
// CHECK-NEXT: "-ivfsoverlay",
137+
// CHECK-NEXT: "-Xcc",
138+
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
97139
// CHECK: ],
98140

99141
/// --------Clang module F
100142
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}F-{{.*}}.pcm",
101143
// CHECK: "commandLine": [
102144
// CHECK: "-vfsoverlay",
103145
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay.yaml",
104-
// CHECK: ],
146+
// CHECK-NEXT: "-vfsoverlay",
147+
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
148+
// CHECK: "-ivfsoverlay",
149+
// CHECK-NEXT: "-Xcc",
150+
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay.yaml",
151+
// CHECK-NEXT: "-Xcc",
152+
// CHECK-NEXT: "-ivfsoverlay",
153+
// CHECK-NEXT: "-Xcc",
154+
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
155+
// CHECK: ]
156+
157+
/// --------Clang module Indirect
158+
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}Indirect-{{.*}}.pcm",
159+
// CHECK-NOT: overlay.yaml
160+
// CHECK: "-vfsoverlay",
161+
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
162+
// CHECK: "-ivfsoverlay",
163+
// CHECK-NEXT: "-Xcc",
164+
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",

0 commit comments

Comments
 (0)