@@ -2338,13 +2338,16 @@ void PrintAST::visitImportDecl(ImportDecl *decl) {
2338
2338
llvm::interleave (decl->getImportPath (),
2339
2339
[&](const ImportPath::Element &Elem) {
2340
2340
if (!Mods.empty ()) {
2341
- Identifier Name = Elem.Item ;
2341
+ // Should print the module real name in case module
2342
+ // aliasing is used (see -module-alias), since that's
2343
+ // the actual binary name.
2344
+ Identifier Name = decl->getASTContext ().getRealModuleName (Elem.Item );
2342
2345
if (Options.MapCrossImportOverlaysToDeclaringModule ) {
2343
2346
if (auto *MD = Mods.front ().getAsSwiftModule ()) {
2344
2347
ModuleDecl *Declaring = const_cast <ModuleDecl*>(MD)
2345
2348
->getDeclaringModuleIfCrossImportOverlay ();
2346
2349
if (Declaring)
2347
- Name = Declaring->getName ();
2350
+ Name = Declaring->getRealName ();
2348
2351
}
2349
2352
}
2350
2353
Printer.printModuleRef (Mods.front (), Name);
@@ -4322,7 +4325,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
4322
4325
Mod = Declaring;
4323
4326
}
4324
4327
4325
- Identifier Name = Mod->getName ();
4328
+ // Should use the module real (binary) name here and everywhere else the
4329
+ // module is printed in case module aliasing is used (see -module-alias)
4330
+ Identifier Name = Mod->getRealName ();
4326
4331
if (Options.UseExportedModuleNames && !ExportedModuleName.empty ()) {
4327
4332
Name = Mod->getASTContext ().getIdentifier (ExportedModuleName);
4328
4333
}
@@ -4343,7 +4348,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
4343
4348
bool isLLDBExpressionModule (ModuleDecl *M) {
4344
4349
if (!M)
4345
4350
return false ;
4346
- return M->getName ().str ().startswith (LLDB_EXPRESSIONS_MODULE_NAME_PREFIX);
4351
+ return M->getRealName ().str ().startswith (LLDB_EXPRESSIONS_MODULE_NAME_PREFIX);
4347
4352
}
4348
4353
4349
4354
bool shouldPrintFullyQualified (TypeBase *T) {
@@ -4374,7 +4379,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
4374
4379
4375
4380
// Don't print qualifiers for types from the standard library.
4376
4381
if (M->isStdlibModule () ||
4377
- M->getName () == M->getASTContext ().Id_ObjectiveC ||
4382
+ M->getRealName () == M->getASTContext ().Id_ObjectiveC ||
4378
4383
M->isSystemModule () ||
4379
4384
isLLDBExpressionModule (M))
4380
4385
return false ;
@@ -4637,7 +4642,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
4637
4642
4638
4643
void visitModuleType (ModuleType *T) {
4639
4644
Printer << " module<" ;
4640
- Printer.printModuleRef (T->getModule (), T->getModule ()->getName ());
4645
+ // Should print the module real name in case module aliasing is
4646
+ // used (see -module-alias), since that's the actual binary name.
4647
+ Printer.printModuleRef (T->getModule (), T->getModule ()->getRealName ());
4641
4648
Printer << " >" ;
4642
4649
}
4643
4650
@@ -5697,13 +5704,13 @@ void ProtocolConformance::printName(llvm::raw_ostream &os,
5697
5704
case ProtocolConformanceKind::Normal: {
5698
5705
auto normal = cast<NormalProtocolConformance>(this );
5699
5706
os << normal->getProtocol ()->getName ()
5700
- << " module " << normal->getDeclContext ()->getParentModule ()->getName ();
5707
+ << " module " << normal->getDeclContext ()->getParentModule ()->getRealName ();
5701
5708
break ;
5702
5709
}
5703
5710
case ProtocolConformanceKind::Self: {
5704
5711
auto self = cast<SelfProtocolConformance>(this );
5705
5712
os << self->getProtocol ()->getName ()
5706
- << " module " << self->getDeclContext ()->getParentModule ()->getName ();
5713
+ << " module " << self->getDeclContext ()->getParentModule ()->getRealName ();
5707
5714
break ;
5708
5715
}
5709
5716
case ProtocolConformanceKind::Specialized: {
0 commit comments