Merge pull request #76269 from xymus/public-module-name

Diagnostics: Intro the public module name concept to hide support modules from clients
This commit is contained in:
Alexis Laferrière
2024-09-09 16:57:12 -07:00
committed by GitHub
18 changed files with 210 additions and 3 deletions

View File

@@ -243,6 +243,8 @@ class ModuleDecl
/// Module name to use when referenced in clients module interfaces.
mutable Identifier ExportAsName;
mutable Identifier PublicModuleName;
public:
/// Produces the components of a given module's full name in reverse order.
///
@@ -502,6 +504,21 @@ public:
ExportAsName = name;
}
/// Public facing name for this module in diagnostics and documentation.
///
/// This always returns a valid name as it defaults to the module name if
/// no public module name is set.
///
/// If `onlyIfImported`, return the normal module name when the module
/// corresponding to the public module name isn't imported. Users working
/// in between both modules will then see the normal module name,
/// this may be more useful for diagnostics at that level.
Identifier getPublicModuleName(bool onlyIfImported) const;
void setPublicModuleName(Identifier name) {
PublicModuleName = name;
}
/// Retrieve the actual module name of an alias used for this module (if any).
///
/// For example, if '-module-alias Foo=Bar' is passed in when building the main module,