================ @@ -556,14 +556,23 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> { copyRecord(*LocSrc, *LocDst, Env); - // If the expr is a glvalue, we can reasonably assume the operator is - // returning T& and thus we can assign it `LocDst`. - if (S->isGLValue()) { + // The assignment operator can have an arbitrary return type. We model the + // return value only if the return type is the same as or a base class of + // the destination type. + if (S->getType().getCanonicalType().getUnqualifiedType() != + LocDst->getType().getCanonicalType().getUnqualifiedType()) { + auto ReturnDecl = S->getType()->getAsCXXRecordDecl(); + auto DstDecl = LocDst->getType()->getAsCXXRecordDecl(); + if (ReturnDecl == nullptr || DstDecl == nullptr) + return; + if (!DstDecl->isDerivedFrom(ReturnDecl)) ---------------- Xazax-hun wrote:
Would we want to create a fresh storage location here? https://github.com/llvm/llvm-project/pull/90898 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits