This patch adds support for attribute "noescape", which is used to tell the compiler that a block passed to a function will not be called after the function returns.
To ensure that the block does not escape, clang imposes the following restrictions on its usage:
- Cannot be passed to a function expecting an escaping block
- Cannot be returned from a function
- Cannot be captured by a block
- Cannot be assigned to a variable
There are other improvements we can make to Sema and CodeGen if the compiler can tell whether a block escapes or not, which should follow this patch.
rdar://problem/19886775