Skip to content

Commit 6f9bebe

Browse files
authored
Merge pull request #41144 from vsapsai/accept-demoted-tagdecl
Make isVisibleFromModule accept TagDecl definitions that were demoted to declarations.
2 parents 3f2fea1 + 0114b4b commit 6f9bebe

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,9 +2705,12 @@ static bool isVisibleFromModule(const ClangModuleUnit *ModuleFilter,
27052705

27062706
// For enums, structs, and unions, only count definitions when looking to
27072707
// see what other modules they appear in.
2708-
if (IsTagDecl)
2709-
if (!cast<clang::TagDecl>(Redeclaration)->isCompleteDefinition())
2708+
if (IsTagDecl) {
2709+
auto TD = cast<clang::TagDecl>(Redeclaration);
2710+
if (!TD->isCompleteDefinition() &&
2711+
!TD->isThisDeclarationADemotedDefinition())
27102712
continue;
2713+
}
27112714

27122715
auto OwningClangModule = getClangTopLevelOwningModule(Redeclaration,
27132716
ClangASTContext);

test/ClangImporter/overlay.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ let encoding: UInt = NSUTF8StringEncoding
1717
let viaTypedef: Redeclaration.NSPoint = AppKit.NSPoint(x: 0, y: 0)
1818
Redeclaration.NSStringToNSString(AppKit.NSStringToNSString("abc")) // expected-warning {{result of call to 'NSStringToNSString' is unused}}
1919

20-
/// The following error should soon be introduced by https://github.com/apple/llvm-project/pull/3497.
21-
let viaStruct: Redeclaration.FooStruct1 = AppKit.FooStruct1() // expected-error * {{module 'AppKit' has no member named 'FooStruct1'}}
20+
let viaStruct: Redeclaration.FooStruct1 = AppKit.FooStruct1()
2221
let forwardDecl: Redeclaration.Tribool = AppKit.Tribool() // expected-error {{no type named 'Tribool' in module 'Redeclaration'}}

0 commit comments

Comments
 (0)