Skip to content

Commit 9ee2667

Browse files
committed
stash
1 parent a10bf21 commit 9ee2667

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6585,6 +6585,12 @@ CxxRecordSemantics::evaluate(Evaluator &evaluator,
65856585
if (hasIteratorAPIAttr(cxxDecl) || isIterator(cxxDecl)) {
65866586
return CxxRecordSemanticsKind::Iterator;
65876587
}
6588+
6589+
if (!cxxDecl->hasUserDeclaredCopyConstructor() &&
6590+
!cxxDecl->hasUserDeclaredMoveConstructor() &&
6591+
hasPointerInSubobjects(cxxDecl)) {
6592+
return CxxRecordSemanticsKind::UnsafePointerMember;
6593+
}
65886594

65896595
if (hasCopyTypeOperations(cxxDecl)) {
65906596
return CxxRecordSemanticsKind::Owned;
@@ -6594,16 +6600,11 @@ CxxRecordSemantics::evaluate(Evaluator &evaluator,
65946600
return CxxRecordSemanticsKind::MoveOnly;
65956601
}
65966602

6597-
if (hasPointerInSubobjects(cxxDecl)) {
6598-
return CxxRecordSemanticsKind::UnsafePointerMember;
6599-
}
6600-
66016603
if (isSufficientlyTrivial(cxxDecl)) {
66026604
return CxxRecordSemanticsKind::Trivial;
66036605
}
66046606

6605-
// How did we get here?
6606-
return CxxRecordSemanticsKind::Owned;
6607+
llvm_unreachable("Could not classify C++ type.");
66076608
}
66086609

66096610
ValueDecl *

lib/ClangImporter/ImportDecl.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,11 @@ namespace {
26052605
ctor);
26062606
}
26072607
clang::CXXConstructorDecl *copyCtor = nullptr;
2608+
clang::CXXConstructorDecl *moveCtor = nullptr;
2609+
if (decl->needsImplicitMoveConstructor()) {
2610+
moveCtor = clangSema.DeclareImplicitMoveConstructor(
2611+
const_cast<clang::CXXRecordDecl *>(decl));
2612+
}
26082613
if (decl->needsImplicitCopyConstructor()) {
26092614
copyCtor = clangSema.DeclareImplicitCopyConstructor(
26102615
const_cast<clang::CXXRecordDecl *>(decl));
@@ -2613,14 +2618,19 @@ namespace {
26132618
// Try to find it.
26142619
for (auto methods : decl->methods()) {
26152620
if (auto declCtor = dyn_cast<clang::CXXConstructorDecl>(methods)) {
2616-
if (declCtor->isCopyConstructor() && declCtor->isDefaulted() &&
2621+
if (declCtor->isDefaulted() &&
26172622
declCtor->getAccess() == clang::AS_public &&
26182623
!declCtor->isDeleted() &&
26192624
// Note: we use "doesThisDeclarationHaveABody" here because
26202625
// that's what "DefineImplicitCopyConstructor" checks.
26212626
!declCtor->doesThisDeclarationHaveABody()) {
2622-
copyCtor = declCtor;
2623-
break;
2627+
if (declCtor->isCopyConstructor()) {
2628+
copyCtor = declCtor;
2629+
break;
2630+
} else if (declCtor->isMoveConstructor()) {
2631+
moveCtor = declCtor;
2632+
break;
2633+
}
26242634
}
26252635
}
26262636
}
@@ -2629,6 +2639,10 @@ namespace {
26292639
clangSema.DefineImplicitCopyConstructor(clang::SourceLocation(),
26302640
copyCtor);
26312641
}
2642+
if (moveCtor) {
2643+
clangSema.DefineImplicitMoveConstructor(clang::SourceLocation(),
2644+
moveCtor);
2645+
}
26322646

26332647
if (decl->needsImplicitDestructor()) {
26342648
auto dtor = clangSema.DeclareImplicitDestructor(

0 commit comments

Comments
 (0)