From 353b33b2bbd9e8715c7a0231681921bcfdfe4cbf Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 17 Jun 2010 23:00:29 +0000 Subject: objective-C++ IRGen: property reference as an lvalue when performing a derived-to-base conversion. Fixes radar 7501812. Added an executable test to llvm-test suite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106247 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index aab54099fd..8655a66bd9 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1818,10 +1818,18 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { cast(DerivedClassTy->getDecl()); LValue LV = EmitLValue(E->getSubExpr()); + llvm::Value *This; + if (LV.isPropertyRef()) { + RValue RV = EmitLoadOfPropertyRefLValue(LV, E->getSubExpr()->getType()); + assert (!RV.isScalar() && "EmitCastLValue"); + This = RV.getAggregateAddr(); + } + else + This = LV.getAddress(); // Perform the derived-to-base conversion llvm::Value *Base = - GetAddressOfBaseClass(LV.getAddress(), DerivedClassDecl, + GetAddressOfBaseClass(This, DerivedClassDecl, E->getBasePath(), /*NullCheckValue=*/false); return LValue::MakeAddr(Base, MakeQualifiers(E->getType())); -- cgit v1.2.3