Skip to content

Commit 8072504

Browse files
committed
[cxx-interop] Check the presence of copy constructor correctly
This removes a longstanding workaround in the import logic for C++ structs: Swift assumed that if a C++ struct has no copy constructor that is explicitly deleted, then the struct is copyable. This is not actually correct. This replaces the workaround with a proper check for the presence of a C++ copy constructor. rdar://136838485
1 parent 81c7fb0 commit 8072504

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7629,8 +7629,9 @@ static bool hasCopyTypeOperations(const clang::CXXRecordDecl *decl) {
76297629
}))
76307630
return false;
76317631

7632-
// TODO: this should probably check to make sure we actually have a copy ctor.
7633-
return true;
7632+
return llvm::any_of(decl->ctors(), [](clang::CXXConstructorDecl *ctor) {
7633+
return ctor->isCopyConstructor();
7634+
});
76347635
}
76357636

76367637
static bool hasMoveTypeOperations(const clang::CXXRecordDecl *decl) {

0 commit comments

Comments
 (0)