This is another attempt to make function-local declarations
(like static variables, structs/classes, and other) be correctly emitted
within a lexical (bracketed) block.
Some ideas were taken from previous attempts [0] and [1].
Limitations:
Since we skip lexical blocks if we couldn't find non-scope children for them,
we need a way to force the emission of blocks that have static locals or local
type declarations but don't have local variables. As a workaround, I
collect such scopes by collectLocalScopesWithDeclsFromCU() and
store them in a set. This set is used later to check whether we need to emit
a lexical block. It, however, lacks information about used records
and typedefs because there is no access to them from a CU.
In this case, we will put the entity to a first available parent scope
(with subprogram as a bound).
Fixes https://bugs.llvm.org/show_bug.cgi?id=19238.
clang's part is at D113743.
[0] https://reviews.llvm.org/D11180
[1] https://reviews.llvm.org/D15976
[2] https://bugs.llvm.org/show_bug.cgi?id=27579
Does this need to map from DIScope (rather than DILocalScope) because it could take a DICommonBlock? If so maybe we should rename this map to remove the "Local".
Or could we possibly make this a map from DISubprogram?