Skip to content

Commit e5e40e5

Browse files
authored
[ClangImporter] Filter import-as-member decls by preferred submodule. (#10626)
That is, if a member is redeclarable, use the module of the definition if possible, and the canonical declaration otherwise. This is consistent with what we do when we actually import the declaration. Without this, we can end up dropping declarations. rdar://problem/32816381 (#10612)
1 parent 036f4ef commit e5e40e5

File tree

7 files changed

+26
-2
lines changed

7 files changed

+26
-2
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7907,8 +7907,9 @@ ClangImporter::Implementation::loadAllMembers(Decl *D, uint64_t extra) {
79077907
for (auto entry : table->lookupGlobalsAsMembers(effectiveClangContext)) {
79087908
auto decl = entry.get<clang::NamedDecl *>();
79097909

7910-
// Only continue members in the same submodule as this extension.
7911-
if (decl->getImportedOwningModule() != submodule) continue;
7910+
// Only include members in the same submodule as this extension.
7911+
if (getClangSubmoduleForDecl(decl) != submodule)
7912+
continue;
79127913

79137914
forEachDistinctName(decl, [&](ImportedName newName,
79147915
ImportNameVersion nameVersion) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct IAMOuter { int x; };
2+
3+
struct IAMInner { int y; };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// The order of these forward-declarations affects whether there was a bug.
2+
struct IAMOuter;
3+
struct IAMInner;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Name: ImportAsMemberSubmodules
2+
Tags:
3+
- Name: IAMInner
4+
SwiftName: IAMOuter.Inner
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Umbrella header.
2+
#import <ImportAsMemberSubmodules/Fwd.h>
3+
#import <ImportAsMemberSubmodules/Actual.h>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
framework module ImportAsMemberSubmodules {
2+
umbrella header "ImportAsMemberSubmodules.h"
3+
export *
4+
module * { export * }
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks %s -verify
2+
3+
import ImportAsMemberSubmodules
4+
5+
let _: IAMOuter.Inner?

0 commit comments

Comments
 (0)