Skip to content

Commit ca53873

Browse files
committed
Don't show private discriminators in simplified demanglings
These are really long and don't tell you anything interesting in backtraces. They can also take up quite a bit of valuable real estate in vertical layouts. rdar://problem/22982415
1 parent 0103fb4 commit ca53873

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

include/swift/Basic/Demangle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct DemangleOptions {
4444
bool ShortenThunk = false;
4545
bool ShortenValueWitness = false;
4646
bool ShortenArchetype = false;
47+
bool ShowPrivateDiscriminators = true;
4748

4849
DemangleOptions() {}
4950

@@ -62,6 +63,7 @@ struct DemangleOptions {
6263
Opt.ShortenThunk = true;
6364
Opt.ShortenValueWitness = true;
6465
Opt.ShortenArchetype = true;
66+
Opt.ShowPrivateDiscriminators = false;
6567
return Opt;
6668
};
6769
};

lib/Basic/Demangle.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,9 +2940,13 @@ void NodePrinter::print(NodePointer pointer, bool asContext, bool suppressType)
29402940
Printer << " #" << (pointer->getChild(0)->getIndex() + 1) << ')';
29412941
return;
29422942
case Node::Kind::PrivateDeclName:
2943-
Printer << '(';
2943+
if (Options.ShowPrivateDiscriminators)
2944+
Printer << '(';
2945+
29442946
print(pointer->getChild(1));
2945-
Printer << " in " << pointer->getChild(0)->getText() << ')';
2947+
2948+
if (Options.ShowPrivateDiscriminators)
2949+
Printer << " in " << pointer->getChild(0)->getText() << ')';
29462950
return;
29472951
case Node::Kind::Module:
29482952
if (Options.DisplayModuleNames)

test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,4 @@ _TTRXFo_iT__iT_zoPs13ErrorProtocol__XFo__dT_zoPS___ ---> reabstraction thunk hel
214214
_TFE1a ---> _TFE1a
215215
_TF21$__lldb_module_for_E0au3$E0Ps13ErrorProtocol_ ---> $__lldb_module_for_E0.$E0.unsafeMutableAddressor : Swift.ErrorProtocol
216216
_TMps10Comparable ---> protocol descriptor for Swift.Comparable
217+
_TFC4testP33_83378C430F65473055F1BD53F3ADCDB71C5doFoofT_T_ ---> test.(C in _83378C430F65473055F1BD53F3ADCDB7).doFoo () -> ()

test/Demangle/Inputs/simplified-manglings.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ _TF8manglingX30Proprostnemluvesky_uybCEdmaEBaFT_T_ ---> Pročprostěnemluvíčes
165165
_TF8manglingXoi7p_qcaDcFTSiSi_Si ---> «+» infix(Int, Int) -> Int
166166
_TF8manglingoi2qqFTSiSi_T_ ---> ?? infix(Int, Int) -> ()
167167
_TFE11ext_structAV11def_structA1A4testfT_T_ ---> A.test() -> ()
168-
_TF13devirt_accessP5_DISC15getPrivateClassFT_CS_P5_DISC12PrivateClass ---> (getPrivateClass in _DISC)() -> (PrivateClass in _DISC)
169-
_TF4mainP5_mainX3wxaFT_T_ ---> (λ in _main)() -> ()
170-
_TF4mainP5_main3abcFT_aS_P5_DISC3xyz ---> (abc in _main)() -> (xyz in _DISC)
168+
_TF13devirt_accessP5_DISC15getPrivateClassFT_CS_P5_DISC12PrivateClass ---> getPrivateClass() -> PrivateClass
169+
_TF4mainP5_mainX3wxaFT_T_ ---> λ() -> ()
170+
_TF4mainP5_main3abcFT_aS_P5_DISC3xyz ---> abc() -> xyz
171171
_TtPMP_ ---> protocol<>.Type
172172
_TFCs13_NSSwiftArray29canStoreElementsOfDynamicTypefPMP_Sb ---> _NSSwiftArray.canStoreElementsOfDynamicType(protocol<>.Type) -> Bool
173173
_TFCs13_NSSwiftArrayg17staticElementTypePMP_ ---> _NSSwiftArray.staticElementType.getter
@@ -196,3 +196,4 @@ _TFe27mangling_generic_extensionsR_S_8RunciblerVS_3Foog1aSi ---> Foo<A where ...
196196
_TFe27mangling_generic_extensionsR_S_8RunciblerVS_3Foog1bx ---> Foo<A where ...>.b.getter
197197
_TTRXFo_iT__iT_zoPs13ErrorProtocol__XFo__dT_zoPS___ ---> thunk
198198
_TFE1a ---> _TFE1a
199+
_TFC4testP33_83378C430F65473055F1BD53F3ADCDB71C5doFoofT_T_ ---> C.doFoo() -> ()

0 commit comments

Comments
 (0)