Instead of visiting all types in the ExternalDefinitions list and
queuing up their conformances, just emit conformances as needed
when they are first referenced.
- Don't forget to walk the top-level 'main' function
- Force _ObjectiveCBridgeable and _BridgedStoredNSError conformances
for types mentioned in apply instructions, existential erasure and
casts
- Only walk each unique CanType once, and skip non-ClangImporter
synthesized conformances completely
- Add a few missing cases
SILGen has the ability to lazily emit ClangImporter-synthesized
conformances. Sema builds a per-SourceFile list of "used" conformances,
which are forced to be emitted by SILGen. All other conformances can be
emitted lazily.
Some of these "used" conformances are in fact not referenced by SILGen
at all, but must exist for emission by IRGen so that they can be
referenced from type metadata accessors, as well as available at
runtime for the dynamic cast machinery.
To handle these cases, add an AST walk to SILGen which emits the types
of stored properties, the superclass of a class, and a few other
things that might not be referenced directly from SIL.
For now, this is all redundant because Sema forces the right
conformances anyway, but that's going to change soon.