33
33
#include " llvm/ADT/STLExtras.h"
34
34
#include " llvm/ADT/SmallVector.h"
35
35
#include " llvm/ADT/StringMap.h"
36
+ #include " llvm/ADT/DenseMap.h"
36
37
#include " llvm/Support/ErrorHandling.h"
37
38
#include " llvm/Support/MD5.h"
38
39
#include < set>
@@ -171,6 +172,12 @@ class ModuleDecl
171
172
// / The ABI name of the module, if it differs from the module name.
172
173
mutable Identifier ModuleABIName;
173
174
175
+ // / The underlying name for an alias used for this module (if any).
176
+ mutable Identifier ModuleUnderlyingName;
177
+
178
+ // / Mapping between aliases and underlying names of imported or referenced modules
179
+ mutable llvm::DenseMap<Identifier, Identifier> ModuleAliasMap;
180
+
174
181
public:
175
182
// / Produces the components of a given module's full name in reverse order.
176
183
// /
@@ -279,6 +286,9 @@ class ModuleDecl
279
286
280
287
using Decl::getASTContext;
281
288
289
+ // / Retrieves the underlying module name given a module alias
290
+ Identifier lookupModuleAlias (Identifier key);
291
+
282
292
// / Retrieves information about which modules are implicitly imported by
283
293
// / each file of this module.
284
294
const ImplicitImportInfo &getImplicitImportInfo () const { return ImportInfo; }
@@ -357,6 +367,20 @@ class ModuleDecl
357
367
ModuleABIName = name;
358
368
}
359
369
370
+ // / Set the mapping between aliases and underlying names of imported or referenced modules
371
+ // / within this module.
372
+ void setModuleAliases (const llvm::StringMap<StringRef> &aliasMap);
373
+
374
+ // / If a module alias is used, set the corresponding underlying name.
375
+ // / It will be used for metadata and mangling.
376
+ void setUnderlyingName (Identifier name) {
377
+ ModuleUnderlyingName = name;
378
+ }
379
+
380
+ // / Retrieve the underlying name of the alias (if any) used for this module.
381
+ // / If no module alias is set, returns getName().
382
+ Identifier getUnderlyingName () const ;
383
+
360
384
// / User-defined module version number.
361
385
llvm::VersionTuple UserModuleVersion;
362
386
void setUserModuleVersion (llvm::VersionTuple UserVer) {
@@ -365,6 +389,7 @@ class ModuleDecl
365
389
llvm::VersionTuple getUserModuleVersion () const {
366
390
return UserModuleVersion;
367
391
}
392
+
368
393
private:
369
394
// / A cache of this module's underlying module and required bystander if it's
370
395
// / an underscored cross-import overlay.
0 commit comments