Skip to content

Commit 1e43ba0

Browse files
committed
[cxx-interp] Don't select the move contstructor if it hasn't been defined.
1 parent 9d5e06c commit 1e43ba0

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,13 +2610,12 @@ namespace {
26102610
}
26112611
clang::CXXConstructorDecl *copyCtor = nullptr;
26122612
clang::CXXConstructorDecl *moveCtor = nullptr;
2613-
if (decl->needsImplicitMoveConstructor()) {
2614-
moveCtor = clangSema.DeclareImplicitMoveConstructor(
2615-
const_cast<clang::CXXRecordDecl *>(decl));
2616-
}
26172613
if (decl->needsImplicitCopyConstructor()) {
26182614
copyCtor = clangSema.DeclareImplicitCopyConstructor(
26192615
const_cast<clang::CXXRecordDecl *>(decl));
2616+
} else if (decl->needsImplicitMoveConstructor()) {
2617+
moveCtor = clangSema.DeclareImplicitMoveConstructor(
2618+
const_cast<clang::CXXRecordDecl *>(decl));
26202619
} else {
26212620
// We may have a defaulted copy constructor that needs to be defined.
26222621
// Try to find it.

lib/IRGen/GenStruct.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,10 @@ namespace {
556556
return nullptr;
557557
for (auto method : cxxRecordDecl->methods()) {
558558
if (auto ctor = dyn_cast<clang::CXXConstructorDecl>(method)) {
559-
if (ctor->isCopyConstructor())
559+
if (ctor->isCopyConstructor() &&
560+
ctor->getAccess() == clang::AS_public &&
561+
ctor->doesThisDeclarationHaveABody() &&
562+
!ctor->isDeleted())
560563
return ctor;
561564
}
562565
}
@@ -570,7 +573,10 @@ namespace {
570573
return nullptr;
571574
for (auto method : cxxRecordDecl->methods()) {
572575
if (auto ctor = dyn_cast<clang::CXXConstructorDecl>(method)) {
573-
if (ctor->isMoveConstructor())
576+
if (ctor->isMoveConstructor() &&
577+
ctor->getAccess() == clang::AS_public &&
578+
ctor->doesThisDeclarationHaveABody() &&
579+
!ctor->isDeleted())
574580
return ctor;
575581
}
576582
}

0 commit comments

Comments
 (0)