Skip to content

Commit aaa9b18

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.
1 parent 71c27a9 commit aaa9b18

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
@@ -7491,8 +7491,9 @@ static bool hasCopyTypeOperations(const clang::CXXRecordDecl *decl) {
74917491
}))
74927492
return false;
74937493

7494-
// TODO: this should probably check to make sure we actually have a copy ctor.
7495-
return true;
7494+
return llvm::any_of(decl->ctors(), [](clang::CXXConstructorDecl *ctor) {
7495+
return ctor->isCopyConstructor();
7496+
});
74967497
}
74977498

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

0 commit comments

Comments
 (0)