aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-03-23 18:43:00 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-03-23 18:43:00 +0000
commit707ea283f5514e2cb633a89f702190f0d798c7ea (patch)
treece24f33b0133e766acda30038acb4a3bca18350d
parent7986ad5f8de58987a3f3f5ec27d6e765f9e14c9a (diff)
Code gen for compound assignment of complex
types using property syntax to access setter/getters. (also radar 7351147). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99307 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprComplex.cpp9
-rw-r--r--test/CodeGenObjC/complex-property.m3
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index ee104b7635..0a0c9149b4 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -524,13 +524,14 @@ EmitCompoundAssign(const CompoundAssignOperator *E,
OpInfo.RHS = EmitCast(E->getRHS(), OpInfo.Ty);
LValue LHSLV = CGF.EmitLValue(E->getLHS());
- assert(!LHSLV.isKVCRef() &&
- "setter/getter access of complex using property syntax NYI");
// We know the LHS is a complex lvalue.
ComplexPairTy LHSComplexPair;
if (LHSLV.isPropertyRef())
LHSComplexPair =
CGF.EmitObjCPropertyGet(LHSLV.getPropertyRefExpr()).getComplexVal();
+ else if (LHSLV.isKVCRef())
+ LHSComplexPair =
+ CGF.EmitObjCPropertyGet(LHSLV.getKVCRefExpr()).getComplexVal();
else
LHSComplexPair = EmitLoadOfComplex(LHSLV.getAddress(),
LHSLV.isVolatileQualified());
@@ -547,6 +548,8 @@ EmitCompoundAssign(const CompoundAssignOperator *E,
if (LHSLV.isPropertyRef())
CGF.EmitObjCPropertySet(LHSLV.getPropertyRefExpr(),
RValue::getComplex(Result));
+ else if (LHSLV.isKVCRef())
+ CGF.EmitObjCPropertySet(LHSLV.getKVCRefExpr(), RValue::getComplex(Result));
else
EmitStoreOfComplex(Result, LHSLV.getAddress(), LHSLV.isVolatileQualified());
// And now return the LHS
@@ -556,6 +559,8 @@ EmitCompoundAssign(const CompoundAssignOperator *E,
IgnoreImagAssign = ignimag;
if (LHSLV.isPropertyRef())
return CGF.EmitObjCPropertyGet(LHSLV.getPropertyRefExpr()).getComplexVal();
+ else if (LHSLV.isKVCRef())
+ return CGF.EmitObjCPropertyGet(LHSLV.getKVCRefExpr()).getComplexVal();
return EmitLoadOfComplex(LHSLV.getAddress(), LHSLV.isVolatileQualified());
}
diff --git a/test/CodeGenObjC/complex-property.m b/test/CodeGenObjC/complex-property.m
index 6d7cda19ec..bd3bfea94b 100644
--- a/test/CodeGenObjC/complex-property.m
+++ b/test/CodeGenObjC/complex-property.m
@@ -3,11 +3,14 @@
@interface A
@property __complex int COMPLEX_PROP;
+- (__complex int)y;
+- (void) setY : (__complex int)rhs;
@end
void f0(A *a) {
_Complex int a1 = 25 + 10i;
a.COMPLEX_PROP += a1;
+ a.y += a1;
}
// CHECK-LP64: internal global [13 x i8] c"COMPLEX_PROP