Skip to content

Commit 5a398c3

Browse files
committed
Revert "[ASTMangler] Add support for mangling generic typealiases."
This reverts commit 410940c. Generic typealias mangling is incomplete, causing demangling and remangling failures on a number of projects. Disable it for now.
1 parent 1c60926 commit 5a398c3

File tree

7 files changed

+6
-42
lines changed

7 files changed

+6
-42
lines changed

include/swift/Demangling/DemangleNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ NODE(BoundGenericClass)
3636
NODE(BoundGenericEnum)
3737
NODE(BoundGenericStructure)
3838
NODE(BoundGenericOtherNominalType)
39-
NODE(BoundGenericTypeAlias)
4039
NODE(BuiltinTypeName)
4140
NODE(CFunctionPointer)
4241
CONTEXT_NODE(Class)

lib/AST/ASTMangler.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -739,31 +739,15 @@ void ASTMangler::appendType(Type type) {
739739
auto aliasTy = cast<NameAliasType>(tybase);
740740

741741
// It's not possible to mangle the context of the builtin module.
742-
// For the DWARF output we want to mangle the type alias + context,
743-
// unless the type alias references a builtin type.
742+
// FIXME: We also cannot yet mangle references to typealiases that
743+
// involve generics.
744744
TypeAliasDecl *decl = aliasTy->getDecl();
745745
if (decl->getModuleContext() == decl->getASTContext().TheBuiltinModule) {
746746
return appendType(aliasTy->getSinglyDesugaredType());
747747
}
748748

749-
if (type->isSpecialized()) {
750-
// Try to mangle the entire name as a substitution.
751-
if (tryMangleSubstitution(tybase))
752-
return;
753-
754-
appendAnyGenericType(decl);
755-
bool isFirstArgList = true;
756-
if (auto *nominalType = type->getAs<NominalType>()) {
757-
if (nominalType->getParent())
758-
type = nominalType->getParent();
759-
}
760-
appendBoundGenericArgs(type, isFirstArgList);
761-
appendRetroactiveConformances(type);
762-
appendOperator("G");
763-
addSubstitution(type.getPointer());
764-
return;
765-
}
766-
749+
// For the DWARF output we want to mangle the type alias + context,
750+
// unless the type alias references a builtin type.
767751
return appendAnyGenericType(decl);
768752
}
769753

lib/Demangling/Demangler.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,9 +1335,6 @@ NodePointer Demangler::demangleBoundGenericArgs(NodePointer Nominal,
13351335
case Node::Kind::OtherNominalType:
13361336
kind = Node::Kind::BoundGenericOtherNominalType;
13371337
break;
1338-
case Node::Kind::TypeAlias:
1339-
kind = Node::Kind::BoundGenericTypeAlias;
1340-
break;
13411338
default:
13421339
return nullptr;
13431340
}

lib/Demangling/NodePrinter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ class NodePrinter {
267267
case Node::Kind::BoundGenericEnum:
268268
case Node::Kind::BoundGenericStructure:
269269
case Node::Kind::BoundGenericOtherNominalType:
270-
case Node::Kind::BoundGenericTypeAlias:
271270
case Node::Kind::BuiltinTypeName:
272271
case Node::Kind::Class:
273272
case Node::Kind::DependentGenericType:
@@ -1541,7 +1540,6 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
15411540
case Node::Kind::BoundGenericStructure:
15421541
case Node::Kind::BoundGenericEnum:
15431542
case Node::Kind::BoundGenericOtherNominalType:
1544-
case Node::Kind::BoundGenericTypeAlias:
15451543
printBoundGeneric(Node);
15461544
return nullptr;
15471545
case Node::Kind::DynamicSelf:

lib/Demangling/OldRemangler.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,11 +1875,6 @@ void Remangler::mangleBoundGenericOtherNominalType(Node *node) {
18751875
mangleAnyNominalType(node, ctx);
18761876
}
18771877

1878-
void Remangler::mangleBoundGenericTypeAlias(Node *node) {
1879-
EntityContext ctx;
1880-
mangleAnyNominalType(node, ctx);
1881-
}
1882-
18831878
void Remangler::mangleTypeList(Node *node) {
18841879
mangleChildNodes(node); // all types
18851880
Out << '_';

lib/Demangling/Remangler.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ void Remangler::mangleAnyNominalType(Node *node) {
463463
case Node::Kind::Enum: return mangleAnyGenericType(node, "O");
464464
case Node::Kind::Class: return mangleAnyGenericType(node, "C");
465465
case Node::Kind::OtherNominalType: return mangleAnyGenericType(node, "XY");
466-
case Node::Kind::TypeAlias: return mangleAnyGenericType(node, "a");
467466
default:
468467
unreachable("bad nominal type kind");
469468
}
@@ -482,8 +481,7 @@ void Remangler::mangleGenericArgs(Node *node, char &Separator) {
482481
case Node::Kind::BoundGenericOtherNominalType:
483482
case Node::Kind::BoundGenericStructure:
484483
case Node::Kind::BoundGenericEnum:
485-
case Node::Kind::BoundGenericClass:
486-
case Node::Kind::BoundGenericTypeAlias: {
484+
case Node::Kind::BoundGenericClass: {
487485
NodePointer unboundType = node->getChild(0);
488486
assert(unboundType->getKind() == Node::Kind::Type);
489487
NodePointer nominalType = unboundType->getChild(0);
@@ -595,10 +593,6 @@ void Remangler::mangleBoundGenericOtherNominalType(Node *node) {
595593
mangleAnyNominalType(node);
596594
}
597595

598-
void Remangler::mangleBoundGenericTypeAlias(Node *node) {
599-
mangleAnyNominalType(node);
600-
}
601-
602596
void Remangler::mangleBuiltinTypeName(Node *node) {
603597
Buffer << 'B';
604598
StringRef text = node->getText();
@@ -2037,7 +2031,6 @@ bool Demangle::isSpecialized(Node *node) {
20372031
case Node::Kind::BoundGenericEnum:
20382032
case Node::Kind::BoundGenericClass:
20392033
case Node::Kind::BoundGenericOtherNominalType:
2040-
case Node::Kind::BoundGenericTypeAlias:
20412034
return true;
20422035

20432036
case Node::Kind::Structure:
@@ -2073,8 +2066,7 @@ NodePointer Demangle::getUnspecialized(Node *node, NodeFactory &Factory) {
20732066
case Node::Kind::BoundGenericStructure:
20742067
case Node::Kind::BoundGenericEnum:
20752068
case Node::Kind::BoundGenericClass:
2076-
case Node::Kind::BoundGenericOtherNominalType:
2077-
case Node::Kind::BoundGenericTypeAlias: {
2069+
case Node::Kind::BoundGenericOtherNominalType: {
20782070
NodePointer unboundType = node->getChild(0);
20792071
assert(unboundType->getKind() == Node::Kind::Type);
20802072
NodePointer nominalType = unboundType->getChild(0);

test/Demangle/Inputs/manglings.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,5 +310,4 @@ _$S3BBBBf0602365061_ ---> _$S3BBBBf0602365061_
310310
_$S3BBBBi0602365061_ ---> _$S3BBBBi0602365061_
311311
_$S3BBBBv0602365061_ ---> _$S3BBBBv0602365061_
312312
_T0lxxxmmmTk ---> _T0lxxxmmmTk
313-
$S4blah8PatatinoaySiGD -> blah.Patatino<Swift.Int>
314313

0 commit comments

Comments
 (0)