Skip to content

Commit bf4e61f

Browse files
committed
Demangler: add an option to print a demangled type name exactly as the runtime function _typeName would do.
1 parent a27822d commit bf4e61f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/swift/Demangling/Demangle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct DemangleOptions {
6262
bool DisplayDebuggerGeneratedModule = true;
6363
bool DisplayStdlibModule = true;
6464
bool DisplayObjCModule = true;
65+
bool PrintForTypeName = false;
66+
6567
/// If this is nonempty, entities in this module name will not be qualified.
6668
llvm::StringRef HidingCurrentModule;
6769
/// A function to render generic parameter names.

lib/Demangling/NodePrinter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,12 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
11311131
Printer << "):";
11321132
}
11331133
print(Node->getChild(1));
1134-
if (Node->getNumChildren() == 3)
1135-
print(Node->getChild(2));
1134+
if (Node->getNumChildren() == 3) {
1135+
// Currently the runtime does not mangle the generic signature.
1136+
// This is an open to-do in swift::_buildDemanglingForContext().
1137+
if (!Options.PrintForTypeName)
1138+
print(Node->getChild(2));
1139+
}
11361140
return nullptr;
11371141
case Node::Kind::Variable:
11381142
return printEntity(Node, asPrefixContext, TypePrinting::WithColon,

0 commit comments

Comments
 (0)