This patch introduces a very simple inter-procedural analysis
between blocks and enclosing functions.
We always analyze blocks first (analysis is done as part of semantic
analysis that goes side-by-side with the parsing process), and at the
moment of reporting we don't know how that block will be actually
used.
This patch introduces new logic delaying reports of the "never called"
warnings on blocks. If we are not sure that the block will be called
exactly once, we shouldn't warn our users about that. Double calls,
however, don't require such delays. While analyzing the enclosing
function, we can actually decide what we should do with those
warnings.
Additionally, as a side effect, we can be more confident about blocks
in such context and can treat them not as escapes, but as direct
calls.
rdar://74090107
Do i understand correctly that you're relying on the order in which your analysis is invoked from Sema? I.e., Sema parses the inner block before the outer function, so it'll analyze the block first, so by the time you see a block expression in the surrounding function you'll already have all diagnostics for the block readily available and no other diagnostics will ever show up, right?