Skip to content

Commit bacfc4f

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 fe796b4 commit bacfc4f

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
@@ -7597,8 +7597,9 @@ static bool hasCopyTypeOperations(const clang::CXXRecordDecl *decl) {
75977597
}))
75987598
return false;
75997599

7600-
// TODO: this should probably check to make sure we actually have a copy ctor.
7601-
return true;
7600+
return llvm::any_of(decl->ctors(), [](clang::CXXConstructorDecl *ctor) {
7601+
return ctor->isCopyConstructor();
7602+
});
76027603
}
76037604

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

0 commit comments

Comments
 (0)