When a block captures an ObjC object pointer, clang emits a retain/release pair to prevent prematurely destroying the object the pointer points to before the block is called or copied.
When the captured object pointer is const-qualified, we can avoid emitting the retain/release pair since the pointer variable cannot be modified in the scope in which the block literal is introduced.
void test(const id x) {
callee(^{ (void)x; });
}This patch implements that optimization.
rdar://problem/28894510