summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-11-17 20:44:25 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-11-17 20:44:25 +0000
commit42a97a94caa7f8699c3af82b1aa4ed87431b6012 (patch)
treefa35eeed364e10b1019fd12a4753d0c51803b59d /clang/lib
parent0f90672ae99d73bd11f16f9b39deb2fe94719434 (diff)
downloadbcm5719-llvm-42a97a94caa7f8699c3af82b1aa4ed87431b6012.tar.gz
bcm5719-llvm-42a97a94caa7f8699c3af82b1aa4ed87431b6012.zip
[ObjC][ARC] Honor noescape attribute for -Warc-retain-cycles
rdar://35409566 Differential Revision: https://reviews.llvm.org/D40141 llvm-svn: 318552
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 6b209cdef7c..e662a5c8b97 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11652,9 +11652,15 @@ void Sema::checkRetainCycles(ObjCMessageExpr *msg) {
}
// Check whether the receiver is captured by any of the arguments.
- for (unsigned i = 0, e = msg->getNumArgs(); i != e; ++i)
- if (Expr *capturer = findCapturingExpr(*this, msg->getArg(i), owner))
+ const ObjCMethodDecl *MD = msg->getMethodDecl();
+ for (unsigned i = 0, e = msg->getNumArgs(); i != e; ++i) {
+ if (Expr *capturer = findCapturingExpr(*this, msg->getArg(i), owner)) {
+ // noescape blocks should not be retained by the method.
+ if (MD && MD->parameters()[i]->hasAttr<NoEscapeAttr>())
+ continue;
return diagnoseRetainCycle(*this, capturer, owner);
+ }
+ }
}
/// Check a property assign to see if it's likely to cause a retain cycle.
OpenPOWER on IntegriCloud