From e1b45a5e6b6f646f2a046e2c1686b005bd841cb5 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Sat, 15 May 2010 23:05:52 +0000 Subject: [PATCH] Fix API gen for objc_msgSend property of aggregate types in Objective-c++ mode. Fixes radar 7986354. llvm-svn: 103887 --- clang/lib/CodeGen/CGExprCXX.cpp | 16 ++++++++++------ clang/test/CodeGenObjCXX/property-objects.mm | 12 +++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 22626fc51987..06d26a485e06 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -264,9 +264,11 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, 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(); + llvm::Value *AggLoc = CreateMemTemp(E->getArg(0)->getType()); + EmitAggExpr(E->getArg(1), AggLoc, false /*VolatileDest*/); + EmitObjCPropertySet(LV.getPropertyRefExpr(), + RValue::getAggregate(AggLoc, false /*VolatileDest*/)); + return RValue::getAggregate(0, false); } else This = LV.getAddress(); @@ -285,9 +287,11 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, 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(); + llvm::Value *AggLoc = CreateMemTemp(E->getArg(0)->getType()); + EmitAggExpr(E->getArg(1), AggLoc, false /*VolatileDest*/); + EmitObjCPropertySet(LV.getPropertyRefExpr(), + RValue::getAggregate(AggLoc, false /*VolatileDest*/)); + return RValue::getAggregate(0, false); } else This = LV.getAddress(); diff --git a/clang/test/CodeGenObjCXX/property-objects.mm b/clang/test/CodeGenObjCXX/property-objects.mm index a4cae087d306..662dacc55d7d 100644 --- a/clang/test/CodeGenObjCXX/property-objects.mm +++ b/clang/test/CodeGenObjCXX/property-objects.mm @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o - | FileCheck %s +// CHECK-NOT: callq _objc_msgSend_stret // CHECK: call void @_ZN1SC1ERKS_ // CHECK: call %class.S* @_ZN1SaSERKS_ // CHECK: call %class.S* @_ZN6CGRectaSERKS_ @@ -20,15 +21,24 @@ struct CGRect { } @property(assign, nonatomic) S position; @property CGRect bounds; +@property CGRect frame; +- (void)setFrame:(CGRect)frameRect; +- (CGRect)frame; - (void) initWithOwner; @end @implementation I @synthesize position; @synthesize bounds; +@synthesize frame; +- (void)setFrame:(CGRect)frameRect {} +- (CGRect)frame {return bounds;} + - (void)initWithOwner { + I* _labelLayer; CGRect labelLayerFrame = self.bounds; labelLayerFrame = self.bounds; + _labelLayer.frame = labelLayerFrame; } @end