This repository was archived by the owner on Nov 1, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -11652,9 +11652,15 @@ void Sema::checkRetainCycles(ObjCMessageExpr *msg) {
11652
11652
}
11653
11653
11654
11654
// Check whether the receiver is captured by any of the arguments.
11655
- for (unsigned i = 0 , e = msg->getNumArgs (); i != e; ++i)
11656
- if (Expr *capturer = findCapturingExpr (*this , msg->getArg (i), owner))
11655
+ const ObjCMethodDecl *MD = msg->getMethodDecl ();
11656
+ for (unsigned i = 0 , e = msg->getNumArgs (); i != e; ++i) {
11657
+ if (Expr *capturer = findCapturingExpr (*this , msg->getArg (i), owner)) {
11658
+ // noescape blocks should not be retained by the method.
11659
+ if (MD && MD->parameters ()[i]->hasAttr <NoEscapeAttr>())
11660
+ continue ;
11657
11661
return diagnoseRetainCycle (*this , capturer, owner);
11662
+ }
11663
+ }
11658
11664
}
11659
11665
11660
11666
// / Check a property assign to see if it's likely to cause a retain cycle.
Original file line number Diff line number Diff line change @@ -198,3 +198,15 @@ __block void(^myBlock)(void) = ^{
198
198
};
199
199
200
200
}
201
+
202
+ typedef void (^a_block_t )(void );
203
+
204
+ @interface HonorNoEscape
205
+ - (void )addStuffUsingBlock : (__attribute__((noescape)) a_block_t)block;
206
+ @end
207
+
208
+ void testNoEscape (HonorNoEscape *obj) {
209
+ [obj addStuffUsingBlock: ^{
210
+ (void )obj; // ok.
211
+ }];
212
+ }
You can’t perform that action at this time.
0 commit comments