From b3ebe946d3bf1e06d3ccbecd11cc16c75b128342 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 10 May 2010 22:57:35 +0000 Subject: [PATCH] Objective-C++ Code gen. Handle code gen. for property reference dot-syntax notation in a varierty of cases. Fixes radar 7964490. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103440 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 11 ++++++++++- lib/CodeGen/CGExprCXX.cpp | 11 ++++++++++- test/CodeGenObjCXX/property-objects.mm | 13 +++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 9ade916f42..8b8b65932b 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1670,7 +1670,16 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { MakeQualifiers(E->getType())); } - case CastExpr::CK_NoOp: + case CastExpr::CK_NoOp: { + LValue LV = EmitLValue(E->getSubExpr()); + // FIXME. assign a meaningfull cast kind. + if (LV.isPropertyRef()) { + RValue RV = EmitLoadOfPropertyRefLValue(LV, E->getSubExpr()->getType()); + llvm::Value *V = RV.isScalar() ? RV.getScalarVal() : RV.getAggregateAddr(); + return LValue::MakeAddr(V, MakeQualifiers(E->getSubExpr()->getType())); + } + return LV; + } case CastExpr::CK_ConstructorConversion: case CastExpr::CK_UserDefinedConversion: case CastExpr::CK_AnyPointerToObjCPointerCast: diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 5714a3e4f1..2b0938ab84 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -261,7 +261,16 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, if (ClassDecl->hasTrivialCopyAssignment()) { assert(!ClassDecl->hasUserDeclaredCopyAssignment() && "EmitCXXOperatorMemberCallExpr - user declared copy assignment"); - llvm::Value *This = EmitLValue(E->getArg(0)).getAddress(); + LValue LV = EmitLValue(E->getArg(0)); + llvm::Value *This; + if (LV.isPropertyRef()) { + RValue RV = EmitLoadOfPropertyRefLValue(LV, E->getArg(0)->getType()); + assert (!RV.isScalar() && "EmitCXXOperatorMemberCallExpr"); + This = RV.getAggregateAddr(); + } + else + This = LV.getAddress(); + llvm::Value *Src = EmitLValue(E->getArg(1)).getAddress(); QualType Ty = E->getType(); EmitAggregateCopy(This, Src, Ty); diff --git a/test/CodeGenObjCXX/property-objects.mm b/test/CodeGenObjCXX/property-objects.mm index cd327c22ca..a4cae087d3 100644 --- a/test/CodeGenObjCXX/property-objects.mm +++ b/test/CodeGenObjCXX/property-objects.mm @@ -1,6 +1,7 @@ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s // CHECK: call void @_ZN1SC1ERKS_ // CHECK: call %class.S* @_ZN1SaSERKS_ +// CHECK: call %class.S* @_ZN6CGRectaSERKS_ class S { public: @@ -9,14 +10,26 @@ public: S (); }; +struct CGRect { + CGRect & operator = (const CGRect &); +}; + @interface I { S position; + CGRect bounds; } @property(assign, nonatomic) S position; +@property CGRect bounds; +- (void) initWithOwner; @end @implementation I @synthesize position; +@synthesize bounds; +- (void)initWithOwner { + CGRect labelLayerFrame = self.bounds; + labelLayerFrame = self.bounds; +} @end int main() {