[cfe-commits] r163017 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaObjC/warn-retain-cycle.m

Fariborz Jahanian fjahanian at apple.com
Fri Aug 31 13:04:47 PDT 2012


Author: fjahanian
Date: Fri Aug 31 15:04:47 2012
New Revision: 163017

URL: http://llvm.org/viewvc/llvm-project?rev=163017&view=rev
Log:
objective-C ARC; detect and warn on retain cycle when
property-dot syntax is used on an object whose
capture causes retain cycle. // rdar://11702054

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaObjC/warn-retain-cycle.m

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=163017&r1=163016&r2=163017&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Aug 31 15:04:47 2012
@@ -5253,6 +5253,12 @@
       if (block->getBlockDecl()->capturesVariable(Variable))
         Visit(block->getBlockDecl()->getBody());
     }
+    
+    void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) {
+      if (Capturer) return;
+      if (OVE->getSourceExpr())
+        Visit(OVE->getSourceExpr());
+    }
   };
 }
 

Modified: cfe/trunk/test/SemaObjC/warn-retain-cycle.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-retain-cycle.m?rev=163017&r1=163016&r2=163017&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/warn-retain-cycle.m (original)
+++ cfe/trunk/test/SemaObjC/warn-retain-cycle.m Fri Aug 31 15:04:47 2012
@@ -24,6 +24,10 @@
   [weakx addBlock: ^{ [x actNow]; }];
   [weakx setBlock: ^{ [x actNow]; }];
   weakx.block = ^{ [x actNow]; };
+
+  // rdar://11702054
+  x.block = ^{ (void)x.actNow; };  // expected-warning {{capturing 'x' strongly in this block is likely to lead to a retain cycle}} \
+                                   // expected-note {{block will be retained by the captured object}}
 }
 
 @interface BlockOwner





More information about the cfe-commits mailing list