`printModuleInterfaceDecl` printes extensions right after the type
they are associated with is printed. Extensions associated with a
type that appears in the "target" module shouldn't be added to
`SwiftDecls` because that would lead to double printing them.
Infer the `-target` argument to `swift-synthesize-interface` to be the host
triple when unspecified instead of emitting an error.
Resolves rdar://156353450.
The `-include-submodules` flag causes the synthesized interface to include
implicit Clang submodules of the module being printed. Since these are
automatically made visible when importing the corresponding top-level module,
it's often useful to have them present in the same synthesized Swift
interface instead of having to make separate invocations to get each
submodule separately.
The `-print-fully-qualified-types` causes type names to be printed with
full module qualification. This is useful when using the synthesized
interface for some other kind of analysis, because it ensures that all
type references explicitly indicate which module they came from, instead
of having to guess scoping and import resolution rules to figure out
which module a reference comes from.
This mode is similar to `swift-symbolgraph-extract`; it takes a subset of compiler
flags to configure the invocation for module loading, as well as a module name
whose contents should be extracted. It does not take any other input files. The
output is a single text file specified by `-o` (or `stdout` if not specified).
While the most common use case for this would be viewing the synthesized Swift
interface for a Clang module, since the implementation simply calls
`swift::ide::printModuleInterface` under the hood, it's usable for any module
that Swift can import. Thus, it could also be used to view a synthesized textual
representation of, say, a compiled `.swiftmodule`.
One could imagine that in the future, we might add more flags to
`swift-synthesize-interface` to modify various `PrintOptions` used when
generating the output, if we think those would be useful.