@@ -350,7 +350,13 @@ class ASTContext final {
350350 // / Cache of module names that fail the 'canImport' test in this context.
351351 mutable llvm::SmallPtrSet<Identifier, 8 > FailedModuleImportNames;
352352
353- // / Mapping between aliases and real (physical) names of imported or referenced modules.
353+ // / Set if a `-module-alias` was passed. Used to store mapping between module aliases and
354+ // / their corresponding real names, and vice versa for a reverse lookup, which is needed to check
355+ // / if the module names appearing in source files are aliases or real names.
356+ // / \see ASTContext::getRealModuleName.
357+ // /
358+ // / The boolean in the value indicates whether or not the entry is keyed by an alias vs real name,
359+ // / i.e. true if the entry is [key: alias_name, value: (real_name, true)].
354360 mutable llvm::DenseMap<Identifier, std::pair<Identifier, bool >> ModuleAliasMap;
355361
356362 // / Retrieve the allocator for the given arena.
@@ -477,25 +483,21 @@ class ASTContext final {
477483 // / specified string.
478484 Identifier getIdentifier (StringRef Str) const ;
479485
480- // / Convert a given module alias map (with `-module-alias` option) to a map of entries that are
481- // / keyed both module aliases and real names along with a boolean indicating whether the entry
482- // / is an alias or a real name.
483- // / An entry with a module alias as key will have value: (real module name, true), and
484- // / an entry with a module real name as key will have value: (module alias, false).
486+ // / Convert a given alias map to a map of Identifiers between module aliases and their actual names.
487+ // / For example, if '-module-alias Foo=X -module-alias Bar=Y' input is passed in, the aliases Foo and Bar are
488+ // / the names of the imported or referenced modules in source files in the main module, and X and Y
489+ // / are the real (physical) module names on disk.
485490 void setModuleAliases (const llvm::StringMap<StringRef> &aliasMap);
486491
487- // / Retrieve the actual module name if a module alias is used via '-module-alias Foo=X', where Foo is
488- // / a module alias and X is the real (physical) name. Returns \p key if no aliasing is used.
489- Identifier getRealModuleName (Identifier key) const ;
490-
491- // / Retrieve the value mapped to the given key.
492- // / \param key A module alias or real name (or non-aliased name) to look up
493- // / \returns A pair of a module alias or real name given \p key, and a boolean indicating if the
494- // / \p key is an alias
495- // / If \p key is a module alias, it returns: (corresponding real name, true)
496- // / if \p key is a module real name, it returns: (corresponding alias, false), and
497- // / if \p key is a non-aliased module name, it returns (key, true).
498- std::pair<Identifier, bool > getRealModuleNameOrAlias (Identifier key) const ;
492+ // / Look up the module alias map by the given \p key.
493+ // /
494+ // / \param key A module alias or real name to look up the map by.
495+ // / \param reverseLookup Default to false, but if true, it will treat the \p key as a real name and
496+ // / look up the alias, which can be used to guard against real names appearing in source files.
497+ // / \returns The real name or alias mapped to the key.
498+ // / If \p reverseLookup is true but the \p key is an alias, it will return an empty Identifier.
499+ // / If no aliasing is used, \p key will be returned.
500+ Identifier getRealModuleName (Identifier key, bool reverseLookup = false ) const ;
499501
500502 // / Decide how to interpret two precedence groups.
501503 Associativity associateInfixOperators (PrecedenceGroupDecl *left,
0 commit comments