[cfe-commits] r147868 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaObjC/arc-property-lifetime.m

Fariborz Jahanian fjahanian at apple.com
Tue Jan 10 11:28:26 PST 2012


Author: fjahanian
Date: Tue Jan 10 13:28:26 2012
New Revision: 147868

URL: http://llvm.org/viewvc/llvm-project?rev=147868&view=rev
Log:
objc-arc: fixes a crash when trying to find out retaining cycle
ownership of property sent to 'super'. // rdar://10640891

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaObjC/arc-property-lifetime.m

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=147868&r1=147867&r2=147868&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Jan 10 13:28:26 2012
@@ -4458,7 +4458,7 @@
   return true;
 }
 
-static bool findRetainCycleOwner(Expr *e, RetainCycleOwner &owner) {
+static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) {
   while (true) {
     e = e->IgnoreParens();
     if (CastExpr *cast = dyn_cast<CastExpr>(e)) {
@@ -4481,7 +4481,7 @@
         return false;
 
       // Try to find a retain cycle in the base.
-      if (!findRetainCycleOwner(ref->getBase(), owner))
+      if (!findRetainCycleOwner(S, ref->getBase(), owner))
         return false;
 
       if (ref->isFreeIvar()) owner.setLocsFrom(ref);
@@ -4524,6 +4524,14 @@
           return false;
 
       owner.Indirect = true;
+      if (pre->isSuperReceiver()) {
+        owner.Variable = S.getCurMethodDecl()->getSelfDecl();
+        if (!owner.Variable)
+          return false;
+        owner.Loc = pre->getLocation();
+        owner.Range = pre->getSourceRange();
+        return true;
+      }
       e = const_cast<Expr*>(cast<OpaqueValueExpr>(pre->getBase())
                               ->getSourceExpr());
       continue;
@@ -4626,7 +4634,7 @@
   // Try to find a variable that the receiver is strongly owned by.
   RetainCycleOwner owner;
   if (msg->getReceiverKind() == ObjCMessageExpr::Instance) {
-    if (!findRetainCycleOwner(msg->getInstanceReceiver(), owner))
+    if (!findRetainCycleOwner(*this, msg->getInstanceReceiver(), owner))
       return;
   } else {
     assert(msg->getReceiverKind() == ObjCMessageExpr::SuperInstance);
@@ -4644,7 +4652,7 @@
 /// Check a property assign to see if it's likely to cause a retain cycle.
 void Sema::checkRetainCycles(Expr *receiver, Expr *argument) {
   RetainCycleOwner owner;
-  if (!findRetainCycleOwner(receiver, owner))
+  if (!findRetainCycleOwner(*this, receiver, owner))
     return;
 
   if (Expr *capturer = findCapturingExpr(*this, argument, owner))

Modified: cfe/trunk/test/SemaObjC/arc-property-lifetime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-property-lifetime.m?rev=147868&r1=147867&r2=147868&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-property-lifetime.m (original)
+++ cfe/trunk/test/SemaObjC/arc-property-lifetime.m Tue Jan 10 13:28:26 2012
@@ -125,3 +125,27 @@
 @synthesize controllerClass = _controllerClass;
 @synthesize controllerId = _controllerId;
 @end
+
+// rdar://10630891
+ at interface UIView @end
+ at class UIColor;
+
+ at interface UIView(UIViewRendering)
+ at property(nonatomic,copy) UIColor *backgroundColor;
+ at end
+
+ at interface UILabel : UIView
+ at end
+
+ at interface MyView 
+ at property (strong) UILabel *label;
+ at end
+
+ at interface MyView2 : MyView @end
+
+ at implementation MyView2
+- (void)foo {
+  super.label.backgroundColor = 0;
+}
+ at end
+





More information about the cfe-commits mailing list