diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-08-31 20:04:47 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-08-31 20:04:47 +0000 |
commit | 0e337543dcadb5baceec59c4f87f48cf204449bb (patch) | |
tree | 8c2550b2992d459ab6c6c6886683b50282b485e0 | |
parent | cbc303006c88b2e658c82f6bafe44e95e04d0301 (diff) | |
download | bcm5719-llvm-0e337543dcadb5baceec59c4f87f48cf204449bb.tar.gz bcm5719-llvm-0e337543dcadb5baceec59c4f87f48cf204449bb.zip |
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
llvm-svn: 163017
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 6 | ||||
-rw-r--r-- | clang/test/SemaObjC/warn-retain-cycle.m | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 137f3e1a5e3..6d6461136b1 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -5253,6 +5253,12 @@ namespace { if (block->getBlockDecl()->capturesVariable(Variable)) Visit(block->getBlockDecl()->getBody()); } + + void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { + if (Capturer) return; + if (OVE->getSourceExpr()) + Visit(OVE->getSourceExpr()); + } }; } diff --git a/clang/test/SemaObjC/warn-retain-cycle.m b/clang/test/SemaObjC/warn-retain-cycle.m index 00fd234a0c0..44d450a3101 100644 --- a/clang/test/SemaObjC/warn-retain-cycle.m +++ b/clang/test/SemaObjC/warn-retain-cycle.m @@ -24,6 +24,10 @@ void test0(Test0 *x) { [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 |