Skip to content

Make isVisibleFromModule accept TagDecl definitions that were demoted to declarations. #41144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2706,9 +2706,12 @@ static bool isVisibleFromModule(const ClangModuleUnit *ModuleFilter,

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

auto OwningClangModule = getClangTopLevelOwningModule(Redeclaration,
ClangASTContext);
Expand Down
3 changes: 1 addition & 2 deletions test/ClangImporter/overlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ let encoding: UInt = NSUTF8StringEncoding
let viaTypedef: Redeclaration.NSPoint = AppKit.NSPoint(x: 0, y: 0)
Redeclaration.NSStringToNSString(AppKit.NSStringToNSString("abc")) // expected-warning {{result of call to 'NSStringToNSString' is unused}}

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