File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1703,8 +1703,8 @@ bool Converter::VisitCallExpr(clang::CallExpr *expr) {
17031703 computed_expr_type_ = ComputedExprType::FreshValue;
17041704 return false ;
17051705 }
1706- computed_expr_type_ = ComputedExprType::FreshValue;
17071706 StrCat (std::format (" {}" , ToString (expr->getArg (0 ))));
1707+ computed_expr_type_ = ComputedExprType::FreshValue;
17081708 return false ;
17091709 }
17101710
@@ -3350,9 +3350,7 @@ bool Converter::VisitCXXConstructExpr(clang::CXXConstructExpr *expr) {
33503350 // Take suppress before recursing into the child.
33513351 bool suppress = PushSuppressIteratorClone::take (*this );
33523352 Convert (expr->getArg (0 ));
3353- bool clone =
3354- ctor->isCopyConstructor () ||
3355- (ctor->isMoveConstructor () && IsUserDefinedDecl (ctor->getParent ()));
3353+ bool clone = ctor->isCopyConstructor () || IsDefaultedMoveConstructor (ctor);
33563354 if (clone && !suppress && !TypeIsCopyable (expr->getType ())) {
33573355 StrCat (" .clone()" );
33583356 }
Original file line number Diff line number Diff line change @@ -269,12 +269,11 @@ bool IsUserDefinedCopyOrMoveConstructor(const clang::CXXConstructorDecl *ctor) {
269269}
270270
271271bool IsDefaultedMoveConstructor (const clang::CXXConstructorDecl *ctor) {
272- return ctor->isMoveConstructor () &&
273- !IsUserDefinedCopyOrMoveConstructor (ctor) &&
272+ return ctor->isMoveConstructor () && !ctor->isUserProvided () &&
274273 IsUserDefinedDecl (ctor->getParent ());
275274}
276275
277- bool IsCopyOrMoveSpecialMember (const clang::CXXMethodDecl *method) {
276+ bool IsCopyOrMoveAssignmentOrCtor (const clang::CXXMethodDecl *method) {
278277 if (const auto *ctor = clang::dyn_cast<clang::CXXConstructorDecl>(method)) {
279278 return ctor->isCopyOrMoveConstructor ();
280279 }
@@ -349,7 +348,7 @@ bool IsConvertibleCXXRecordDecl(const clang::CXXRecordDecl *decl) {
349348 return method->getDefinition () || method->isPureVirtual () ||
350349 method->getTemplateInstantiationPattern () ||
351350 method->getDescribedFunctionTemplate () ||
352- IsCopyOrMoveSpecialMember (method);
351+ IsCopyOrMoveAssignmentOrCtor (method);
353352 });
354353}
355354
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ bool IsUserDefinedCopyOrMoveConstructor(const clang::CXXConstructorDecl *ctor);
6969
7070bool IsDefaultedMoveConstructor (const clang::CXXConstructorDecl *ctor);
7171
72- bool IsCopyOrMoveSpecialMember (const clang::CXXMethodDecl *method);
72+ bool IsCopyOrMoveAssignmentOrCtor (const clang::CXXMethodDecl *method);
7373
7474clang::CXXConstructorDecl *
7575GetUserDefinedCopyConstructor (const clang::RecordDecl *decl);
Original file line number Diff line number Diff line change @@ -1873,6 +1873,10 @@ bool ConverterRefCount::VisitCXXConstructExpr(clang::CXXConstructExpr *expr) {
18731873 return false ;
18741874 }
18751875
1876+ // Default move is translated using a bitwise .clone() implementation.
1877+ // Bitwise clone is only satisfied by default copy constructor. If the copy
1878+ // constructor is user defined, then default move calls copy constructor,
1879+ // which is wrong.
18761880 if (IsDefaultedMoveConstructor (ctor) &&
18771881 !HasDefaultedCopyConstructor (ctor->getParent ())) {
18781882 llvm::report_fatal_error (" defaulted move constructor without a fieldwise "
You can’t perform that action at this time.
0 commit comments