Skip to content

Commit 96e8ec3

Browse files
committed
[Dependency Scanning] Distinguish Swift Textual and Swift Binary modules when resolving direct dependencies
The intent is two-fold: 1. This fixes a bug where we would only attempt to resolve direct dependencies as Clang modules for Swift Binary modules. 2. Ensures that we only query the presence of a Bridging Header for textual Swift modules. Resolves rdar://73015075
1 parent 7e6536d commit 96e8ec3

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ resolveDirectDependencies(CompilerInstance &instance, ModuleDependencyID module,
156156
InterfaceSubContextDelegate &ASTDelegate) {
157157
auto &ctx = instance.getASTContext();
158158
auto knownDependencies = *cache.findDependencies(module.first, module.second);
159-
auto isSwift = knownDependencies.isSwiftTextualModule();
159+
auto isSwiftInterface = knownDependencies.isSwiftTextualModule();
160+
auto isSwift = isSwiftInterface || knownDependencies.isSwiftBinaryModule();
160161

161162
// Find the dependencies of every module this module directly depends on.
162163
std::set<ModuleDependencyID> result;
@@ -171,7 +172,7 @@ resolveDirectDependencies(CompilerInstance &instance, ModuleDependencyID module,
171172
}
172173
}
173174

174-
if (isSwift) {
175+
if (isSwiftInterface) {
175176
// A record of all of the Clang modules referenced from this Swift module.
176177
std::vector<std::string> allClangModules;
177178
llvm::StringSet<> knownModules;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %empty-directory(%t)
2+
3+
import EWrapper
4+
5+
// Step 1: Put the textual interface for E in the right place
6+
// RUN: cp %S/Inputs/Swift/E.swiftinterface %t/E.swiftinterface
7+
// Step 1: Build a swift interface into a binary module
8+
// RUN: %target-swift-frontend -compile-module-from-interface %S/Inputs/Swift/EWrapper.swiftinterface -o %t/EWrapper.swiftmodule -I %t
9+
// Step 3: scan dependency should give us the binary module and a textual swift dependency from it
10+
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -I %t
11+
// Step 4: Verify
12+
// RUN: %FileCheck %s < %t/deps.json
13+
14+
// CHECK: "modulePath": "{{.*}}EWrapper.swiftmodule"
15+
// CHECK-NEXT: "directDependencies": [
16+
// CHECK-NEXT: {
17+
// CHECK-NEXT: "swift": "E"
18+
// CHECK-NEXT: },
19+
// CHECK-NEXT: {
20+
// CHECK-NEXT: "swift": "Swift"
21+
// CHECK-NEXT: },
22+
// CHECK-NEXT: {
23+
// CHECK-NEXT: "swift": "SwiftOnoneSupport"
24+
// CHECK-NEXT: }
25+
// CHECK-NEXT: ],

0 commit comments

Comments
 (0)