diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2012-06-15 23:51:06 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2012-06-15 23:51:06 +0000 |
| commit | 32f498a675df990901e6659d610dc740f9423228 (patch) | |
| tree | 44d18c532f9539fad16e942a555158c8bc1a03bf /lib/CodeGen/CGExpr.cpp | |
| parent | 50dc12ad05d4a3a57e83852756498afce4307a77 (diff) | |
Make the ".*" operator work correctly when the base is a prvalue and the field has a non-trivial copy constructor. PR13097.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 198a9bcd6f..0f794487b9 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -156,7 +156,11 @@ namespace { /// \brief An adjustment to be made to the temporary created when emitting a /// reference binding, which accesses a particular subobject of that temporary. struct SubobjectAdjustment { - enum { DerivedToBaseAdjustment, FieldAdjustment } Kind; + enum { + DerivedToBaseAdjustment, + FieldAdjustment, + MemberPointerAdjustment + } Kind; union { struct { @@ -165,6 +169,11 @@ namespace { } DerivedToBase; FieldDecl *Field; + + struct { + const MemberPointerType *MPT; + llvm::Value *Ptr; + } Ptr; }; SubobjectAdjustment(const CastExpr *BasePath, @@ -178,6 +187,12 @@ namespace { : Kind(FieldAdjustment) { this->Field = Field; } + + SubobjectAdjustment(const MemberPointerType *MPT, llvm::Value *Ptr) + : Kind(MemberPointerAdjustment) { + this->Ptr.MPT = MPT; + this->Ptr.Ptr = Ptr; + } }; } @@ -345,6 +360,15 @@ EmitExprForReferenceBinding(CodeGenFunction &CGF, const Expr *E, continue; } } + } else if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) { + if (BO->isPtrMemOp()) { + assert(BO->getLHS()->isRValue()); + E = BO->getLHS(); + const MemberPointerType *MPT = + BO->getRHS()->getType()->getAs<MemberPointerType>(); + llvm::Value *Ptr = CGF.EmitScalarExpr(BO->getRHS()); + Adjustments.push_back(SubobjectAdjustment(MPT, Ptr)); + } } if (const OpaqueValueExpr *opaque = dyn_cast<OpaqueValueExpr>(E)) @@ -417,6 +441,11 @@ EmitExprForReferenceBinding(CodeGenFunction &CGF, const Expr *E, break; } + case SubobjectAdjustment::MemberPointerAdjustment: { + Object = CGF.CGM.getCXXABI().EmitMemberDataPointerAddress( + CGF, Object, Adjustment.Ptr.Ptr, Adjustment.Ptr.MPT); + break; + } } } |
