[cfe-commits] r112729 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprCXX.cpp test/CodeGenObjCXX/property-objects.mm

Fariborz Jahanian fjahanian at apple.com
Wed Sep 1 12:36:41 PDT 2010


Author: fjahanian
Date: Wed Sep  1 14:36:41 2010
New Revision: 112729

URL: http://llvm.org/viewvc/llvm-project?rev=112729&view=rev
Log:
Fix IRGen when property-dot syntax used to access
a c++ class object 'ivar'. Fixes radar 8366604.


Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
    cfe/trunk/test/CodeGenObjCXX/property-objects.mm

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=112729&r1=112728&r2=112729&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Sep  1 14:36:41 2010
@@ -1753,9 +1753,11 @@
     if (E->getSubExpr()->Classify(getContext()).getKind() 
                                           != Expr::Classification::CL_PRValue) {
       LValue LV = EmitLValue(E->getSubExpr());
-      if (LV.isPropertyRef()) {
+      if (LV.isPropertyRef() || LV.isKVCRef()) {
         QualType QT = E->getSubExpr()->getType();
-        RValue RV = EmitLoadOfPropertyRefLValue(LV, QT);
+        RValue RV = 
+          LV.isPropertyRef() ? EmitLoadOfPropertyRefLValue(LV, QT) 
+                             : EmitLoadOfKVCRefLValue(LV, QT);
         assert(!RV.isScalar() && "EmitCastLValue-scalar cast of property ref");
         llvm::Value *V = RV.getAggregateAddr();
         return MakeAddrLValue(V, QT);
@@ -1810,8 +1812,11 @@
     
     LValue LV = EmitLValue(E->getSubExpr());
     llvm::Value *This;
-    if (LV.isPropertyRef()) {
-      RValue RV = EmitLoadOfPropertyRefLValue(LV, E->getSubExpr()->getType());
+    if (LV.isPropertyRef() || LV.isKVCRef()) {
+      QualType QT = E->getSubExpr()->getType();
+      RValue RV = 
+        LV.isPropertyRef() ? EmitLoadOfPropertyRefLValue(LV, QT)
+                           : EmitLoadOfKVCRefLValue(LV, QT);
       assert (!RV.isScalar() && "EmitCastLValue");
       This = RV.getAggregateAddr();
     }

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=112729&r1=112728&r2=112729&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Wed Sep  1 14:36:41 2010
@@ -203,11 +203,17 @@
              "EmitCXXOperatorMemberCallExpr - user declared copy assignment");
       LValue LV = EmitLValue(E->getArg(0));
       llvm::Value *This;
-      if (LV.isPropertyRef()) {
+      if (LV.isPropertyRef() || LV.isKVCRef()) {
         llvm::Value *AggLoc  = CreateMemTemp(E->getArg(1)->getType());
         EmitAggExpr(E->getArg(1), AggLoc, false /*VolatileDest*/);
-        EmitObjCPropertySet(LV.getPropertyRefExpr(),
-                            RValue::getAggregate(AggLoc, false /*VolatileDest*/));
+        if (LV.isPropertyRef())
+          EmitObjCPropertySet(LV.getPropertyRefExpr(),
+                              RValue::getAggregate(AggLoc, 
+                                                   false /*VolatileDest*/));
+        else
+          EmitObjCPropertySet(LV.getKVCRefExpr(),
+                              RValue::getAggregate(AggLoc, 
+                                                   false /*VolatileDest*/));
         return RValue::getAggregate(0, false);
       }
       else
@@ -226,8 +232,11 @@
                                    FPT->isVariadic());
   LValue LV = EmitLValue(E->getArg(0));
   llvm::Value *This;
-  if (LV.isPropertyRef()) {
-    RValue RV = EmitLoadOfPropertyRefLValue(LV, E->getArg(0)->getType());
+  if (LV.isPropertyRef() || LV.isKVCRef()) {
+    QualType QT = E->getArg(0)->getType();
+    RValue RV = 
+      LV.isPropertyRef() ? EmitLoadOfPropertyRefLValue(LV, QT)
+                         : EmitLoadOfKVCRefLValue(LV, QT);
     assert (!RV.isScalar() && "EmitCXXOperatorMemberCallExpr");
     This = RV.getAggregateAddr();
   }

Modified: cfe/trunk/test/CodeGenObjCXX/property-objects.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-objects.mm?rev=112729&r1=112728&r2=112729&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/property-objects.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/property-objects.mm Wed Sep  1 14:36:41 2010
@@ -25,6 +25,8 @@
 - (void)setFrame:(CGRect)frameRect;
 - (CGRect)frame;
 - (void) initWithOwner;
+- (struct CGRect)extent;
+- (void)dealloc;
 @end
 
 @implementation I
@@ -40,6 +42,12 @@
   labelLayerFrame = self.bounds;
   _labelLayer.frame = labelLayerFrame;
 }
+// rdar://8366604
+- (void)dealloc
+  {
+      CGRect cgrect = self.extent;
+  }
+- (struct CGRect)extent {return bounds;}
 @end
 
 int main() {





More information about the cfe-commits mailing list