Currently the Swift compiler makes these instructions with SILLocations marked
as autgenerated. While this allows for somewhat smoother stepping in some cases,
it can also make some debugging tasks harder due to missing source location
information, for example, when attributing memory allocations.
This patch makes these locations available again, based on that a debug info
consumer could consider filtering them out by recognizing that a source location
is on the opening `{` of a closure, but inside the scope of the function the
closure is defined in.
rdar://127095833
This patch replaces the stateful generation of SILScope information in
SILGenFunction with data derived from the ASTScope hierarchy, which should be
100% in sync with the scopes needed for local variables. The goal is to
eliminate the surprising effects that the stack of cleanup operations can have
on the current state of SILBuilder leading to a fully deterministic (in the
sense of: predictible by a human) association of SILDebugScopes with
SILInstructions. The patch also eliminates the need to many workarounds. There
are still some accomodations for several Sema transformation passes such as
ResultBuilders, which don't correctly update the source locations when moving
around nodes. If these were implemented as macros, this problem would disappear.
This necessary rewrite of the macro scope handling included in this patch also
adds proper support nested macro expansions.
This fixes
rdar://88274783
and either fixes or at least partially addresses the following:
rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288