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
Oh! I hadn't noticed that you were adding this to ExtParameterInfo. You're modifying the function type system; there's a lot of complexity to do that properly which you haven't done in this patch at all. That's especially true because, unlike all these other ExtParameterInfo cases, there's a natural subtyping rule for escaping parameters: a function type that takes a non-escaping parameter should be implicitly convertible to be a function type that takes an escaping parameter. You will also need to update a bunch of things, including the type printer, the mangler, the C++ function conversion rules, the C type compatibility rules, the redeclaration type matcher, and maybe even template argument deduction. It's a big thing to do.
You will want Sema tests in C, ObjC, C++, and ObjC++.