Skip to content

Commit dbf220b

Browse files
committed
On 'canImport' of Clang submodules of modules with an umbrella header, attempt to infer the submodule
Resolves rdar://124163264
1 parent 1752b48 commit dbf220b

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,7 @@ bool ClangImporter::canImportModule(ImportPath::Module modulePath,
20392039

20402040
if (modulePath.hasSubmodule()) {
20412041
for (auto &component : modulePath.getSubmodulePath()) {
2042-
clangModule = clangModule->findSubmodule(component.Item.str());
2042+
clangModule = clangModule->findOrInferSubmodule(component.Item.str());
20432043

20442044
// Special case: a submodule named "Foo.Private" can be moved to a
20452045
// top-level module named "Foo_Private". Clang has special support for
@@ -2187,7 +2187,7 @@ ModuleDecl *ClangImporter::Implementation::loadModuleClang(
21872187
// Verify that the submodule exists.
21882188
clang::Module *submodule = clangModule;
21892189
for (auto &component : path.getSubmodulePath()) {
2190-
submodule = submodule->findSubmodule(component.Item.str());
2190+
submodule = submodule->findOrInferSubmodule(component.Item.str());
21912191

21922192
// Special case: a submodule named "Foo.Private" can be moved to a top-level
21932193
// module named "Foo_Private". Clang has special support for this.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void funcInferred(void);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#import <WithInferredClangModule/InferredClangModule.h>
2+
void funcWith(void);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework module WithInferredClangModule [system] {
2+
header "WithInferredClangModule.h"
3+
umbrella "Headers"
4+
5+
export *
6+
explicit module * { export * }
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -F %S/Inputs/Frameworks
3+
// RUN: %validate-json %t/deps.json | %FileCheck %s
4+
5+
#if canImport(WithInferredClangModule.InferredClangModule)
6+
import ScannerTestKit
7+
#endif
8+
9+
// Ensure that the 'WithInferredClangModule.InferredClangModule' can be imported
10+
// CHECK: "swift": "ScannerTestKit"

0 commit comments

Comments
 (0)