Allow one to separately specify the ABI name of a module.

Introduce a new compiler flag `-module-abi-name <name>` that uses the
given name as the ABI name for the module (rather than the module's
name in source code). The ABI name impacts name mangling and metadata.
This commit is contained in:
Doug Gregor
2021-03-11 11:36:10 -08:00
parent 6f4f9f8c0f
commit 2a28fed34d
22 changed files with 111 additions and 7 deletions

View File

@@ -166,6 +166,9 @@ class ModuleDecl : public DeclContext, public TypeDecl {
friend class DirectOperatorLookupRequest;
friend class DirectPrecedenceGroupLookupRequest;
/// The ABI name of the module, if it differs from the module name.
Identifier ModuleABIName;
public:
/// Produces the components of a given module's full name in reverse order.
///
@@ -343,6 +346,17 @@ public:
void getDeclaredCrossImportBystanders(
SmallVectorImpl<Identifier> &bystanderNames);
/// Retrieve the ABI name of the module, which is used for metadata and
/// mangling.
Identifier getABIName() const {
return ModuleABIName.empty() ? getName() : ModuleABIName;
}
/// Set the ABI name of the module;
void setABIName(Identifier name) {
ModuleABIName = name;
}
private:
/// A cache of this module's underlying module and required bystander if it's
/// an underscored cross-import overlay.