Skip to content

Commit 71f2a26

Browse files
committed
Demangling: Update NodePrinter for primitive AnyObject
1 parent b57b4cf commit 71f2a26

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/Demangling/NodePrinter.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,10 @@ class NodePrinter {
278278
case Node::Kind::ProtocolList:
279279
return Node->getChild(0)->getNumChildren() <= 1;
280280

281-
case Node::Kind::ProtocolListWithClass:
282281
case Node::Kind::ProtocolListWithAnyObject:
282+
return Node->getChild(0)->getChild(0)->getNumChildren() == 0;
283+
284+
case Node::Kind::ProtocolListWithClass:
283285
case Node::Kind::Allocator:
284286
case Node::Kind::ArgumentTuple:
285287
case Node::Kind::AssociatedTypeMetadataAccessor:
@@ -628,7 +630,8 @@ class NodePrinter {
628630
static bool isExistentialType(NodePointer node) {
629631
return (node->getKind() == Node::Kind::ExistentialMetatype ||
630632
node->getKind() == Node::Kind::ProtocolList ||
631-
node->getKind() == Node::Kind::ProtocolListWithClass);
633+
node->getKind() == Node::Kind::ProtocolListWithClass ||
634+
node->getKind() == Node::Kind::ProtocolListWithAnyObject);
632635
}
633636

634637
/// Print the relevant parameters and return the new index.
@@ -1362,7 +1365,10 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
13621365
NodePointer superclass = Node->getChild(1);
13631366
print(superclass);
13641367
Printer << " & ";
1365-
printChildren(protocols, " & ");
1368+
if (protocols->getNumChildren() < 1)
1369+
return nullptr;
1370+
NodePointer type_list = protocols->getChild(0);
1371+
printChildren(type_list, " & ");
13661372
return nullptr;
13671373
}
13681374
case Node::Kind::ProtocolListWithAnyObject: {
@@ -1371,12 +1377,14 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
13711377
NodePointer protocols = Node->getChild(0);
13721378
if (protocols->getNumChildren() < 1)
13731379
return nullptr;
1374-
if (protocols->getChild(0)->getNumChildren() == 0) {
1375-
Printer << "AnyObject";
1376-
} else {
1377-
printChildren(protocols->getChild(0), " & ");
1378-
Printer << " & AnyObject";
1380+
NodePointer type_list = protocols->getChild(0);
1381+
if (type_list->getNumChildren() > 0) {
1382+
printChildren(type_list, " & ");
1383+
Printer << " & ";
13791384
}
1385+
if (Options.QualifyEntities)
1386+
Printer << "Swift.";
1387+
Printer << "AnyObject";
13801388
return nullptr;
13811389
}
13821390
case Node::Kind::AssociatedType:

0 commit comments

Comments
 (0)