[ModuleInterface] Intro export-as for Swift modules

Introduce a new flag `-export-as` to specify a name used to identify the
target module in swiftinterfaces. This provides an analoguous feature
for Swift module as Clang's `export_as` feature.

In practice it should be used when a lower level module `MyKitCore` is
desired to be shown publicly as a downstream module `MyKit`. This should
be used in conjunction with `@_exported import MyKitCore` from `MyKit`
that allows clients to refer to all services as being part of `MyKit`,
while the new `-export-as MyKit` from `MyKitCore` will ensure that the
clients swiftinterfaces also use the `MyKit` name for all services.

In the current implementation, the export-as name is used in the
module's clients and not in the declarer's swiftinterface (e.g.
`MyKitCore`'s swiftinterface still uses the `MyKitCore` module name).
This way the module swiftinterface can be verified. In the future, we
may want a similar behavior for other modules in between `MyKitCore` and
`MyKit` as verifying a swiftinterface referencing `MyKit` without it
being imported would fail.

rdar://103888618
This commit is contained in:
Alexis Laferrière
2023-01-26 14:23:55 -08:00
parent 35553d9306
commit 39fb1c5f55
17 changed files with 152 additions and 3 deletions

View File

@@ -535,6 +535,11 @@ public:
StringRef getModulePackageName() const {
return Core->ModulePackageName;
}
StringRef getModuleExportAsName() const {
return Core->ModuleExportAsName;
}
/// The ABI name of the module.
StringRef getModuleABIName() const {
return Core->ModuleABIName;