]> granicus.if.org Git - clang/commitdiff
Code gen for compound assignment of complex
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 23 Mar 2010 18:43:00 +0000 (18:43 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 23 Mar 2010 18:43:00 +0000 (18:43 +0000)
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

lib/CodeGen/CGExprComplex.cpp
test/CodeGenObjC/complex-property.m

index ee104b763564a1c3a19781660a7e93757493c3fb..0a0c9149b41bf798839631ad3917a173114c876a 100644 (file)
@@ -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());
 }
 
index 6d7cda19ec40eab3062a61de0c13d6fa58f47e48..bd3bfea94b549a83e52fed125772bef86db12aec 100644 (file)
@@ -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