If a function body is emitted, all of the declarations inside that function
body must be emitted, too. Previously, lazy var initializers were being skipped
regardless of whether the function containing them was skipped, resulting in
SIL verification errors (which were correctly predicting linker errors).
Resolves rdar://134708502.
Centralize the exportability checking logic for nested functions in the
`DeclExportabilityVisitor` utility. This logic was previously added to SILGen
but there should not be special casing for nested functions at that layer.
Instances of `MacroExpansionDecl` may be found in the AST when declarations are
expanded from freestanding declaration macros and therefore exportability
computations must be prepared to handle them.
Resolves rdar://119449439
Extract `ExternallyAccessibleDeclVisitor` from `Serialization.cpp` into its own
header and rename it to `DeclExportabilityVisitor` to better align with
terminology in other parts of the compiler. Ideally, `DeclExportabilityVisitor`
should become the canoncial implementation of for exportability checks,
consolidating logic that is currently spread between serialization, module
interface printing, TBDGen, and type checking. For now, it is only used in
serialization to implement serialization safety checks.