Skip to content

Commit fc8a24a

Browse files
committed
[ClangImporter] Filter import-as-member decls by preferred submodule.
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
1 parent ae34243 commit fc8a24a

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
@@ -7872,8 +7872,9 @@ ClangImporter::Implementation::loadAllMembers(Decl *D, uint64_t extra) {
78727872
for (auto entry : table->lookupGlobalsAsMembers(effectiveClangContext)) {
78737873
auto decl = entry.get<clang::NamedDecl *>();
78747874

7875-
// Only continue members in the same submodule as this extension.
7876-
if (decl->getImportedOwningModule() != submodule) continue;
7875+
// Only include members in the same submodule as this extension.
7876+
if (getClangSubmoduleForDecl(decl) != submodule)
7877+
continue;
78777878

78787879
forEachDistinctName(decl, [&](ImportedName newName,
78797880
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)