[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 16:33:35 PDT 2019
dexonsmith added a comment.
In D58514#1428520 <https://reviews.llvm.org/D58514#1428520>, @ahatanak wrote:
> That code doesn't crash because the block is retained at the entry of `bar` and ARC optimizer doesn't remove the retain/release pairs in `bar`.
Oops, I meant:
typedef void (^BlockTy)();
BlockTy sb;
__weak BlockTy wb;
void bar(BlockTy b) {
wb = b;
sb = b;
}
void foo(id a) {
bar(^{ NSLog(@"foo %@", a); });
}
int main() {
auto x = [NSObject new];
foo(x);
sb();
wb();
return 0;
}
Is it the same? Does `b` get retained at the entry to `bar()`?
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58514/new/
https://reviews.llvm.org/D58514
More information about the cfe-commits
mailing list