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
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index ee104b7..0a0c914 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -524,13 +524,14 @@
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 @@
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 @@
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 6d7cda1..bd3bfea 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