Skip to content

Commit 9de29e9

Browse files
committed
[cxx-interop] Allow some C++ constructors in public Swift interfaces
This is a follow-up to 8859b62. This resolves compiler errors when trying to rebuild System.swiftmodule from its textual interface with Xcode 16.1. rdar://140203932 rdar://141124318
1 parent 5aacff4 commit 9de29e9

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/Sema/TypeCheckAccess.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,8 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
18281828
}
18291829
};
18301830

1831+
bool isFragileClangDecl(const clang::Decl *decl);
1832+
18311833
bool isFragileClangType(clang::QualType type) {
18321834
if (type.isNull())
18331835
return true;
@@ -1845,17 +1847,16 @@ bool isFragileClangType(clang::QualType type) {
18451847
return true;
18461848
}
18471849

1848-
bool isFragileClangNode(const ClangNode &node) {
1849-
auto *decl = node.getAsDecl();
1850-
if (!decl)
1851-
return false;
1850+
bool isFragileClangDecl(const clang::Decl *decl) {
18521851
// Namespaces by themselves don't impact ABI.
18531852
if (isa<clang::NamespaceDecl>(decl))
18541853
return false;
18551854
// Objective-C type declarations are compatible with library evolution.
18561855
if (isa<clang::ObjCContainerDecl>(decl))
18571856
return false;
18581857
if (auto *fd = dyn_cast<clang::FunctionDecl>(decl)) {
1858+
if (auto *ctorDecl = dyn_cast<clang::CXXConstructorDecl>(fd))
1859+
return isFragileClangDecl(ctorDecl->getParent());
18591860
if (!isa<clang::CXXMethodDecl>(decl) &&
18601861
!isFragileClangType(fd->getDeclaredReturnType())) {
18611862
for (const auto *param : fd->parameters()) {
@@ -1894,6 +1895,13 @@ bool isFragileClangNode(const ClangNode &node) {
18941895
return true;
18951896
}
18961897

1898+
bool isFragileClangNode(const ClangNode &node) {
1899+
auto *decl = node.getAsDecl();
1900+
if (!decl)
1901+
return false;
1902+
return isFragileClangDecl(decl);
1903+
}
1904+
18971905
} // end anonymous namespace
18981906

18991907
/// Returns the kind of origin, implementation-only import or SPI declaration,

0 commit comments

Comments
 (0)