Skip to content

Commit 7b3290c

Browse files
authored
Merge pull request #14993 from eeckstein/fix-demangler
demangler: fix crashes for malformed symbols
2 parents a75f309 + da322a2 commit 7b3290c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/Demangling/Demangler.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,7 @@ NodePointer Demangler::demangleLocalIdentifier() {
873873
NodePointer name = popNode();
874874
NodePointer result = createNode(Node::Kind::RelatedEntityDeclName,
875875
StringRef(&relatedEntityKind, 1));
876-
result->addChild(name, *this);
877-
return result;
876+
return addChild(result, name);
878877
}
879878
NodePointer discriminator = demangleIndexAsNode();
880879
NodePointer name = popNode(isDeclName);
@@ -2250,9 +2249,9 @@ NodePointer Demangler::demangleSpecialType() {
22502249
auto name = popNode(Node::Kind::Identifier);
22512250
auto parent = popContext();
22522251
auto anon = createNode(Node::Kind::AnonymousContext);
2253-
anon->addChild(name, *this);
2254-
anon->addChild(parent, *this);
2255-
anon->addChild(types, *this);
2252+
anon = addChild(anon, name);
2253+
anon = addChild(anon, parent);
2254+
anon = addChild(anon, types);
22562255
return anon;
22572256
}
22582257
case 'e':

test/Demangle/Inputs/manglings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,5 @@ _T0So11CrappyColorVs16RawRepresentableSCMA --> reflection metadata associated ty
308308
$S28protocol_conformance_records15NativeValueTypeVAA8RuncibleAAMc --> protocol conformance descriptor for protocol_conformance_records.NativeValueType : protocol_conformance_records.Runcible in protocol_conformance_records
309309
$SSC9SomeErrorLeVD ---> __C_Synthesized.related decl 'e' for SomeError
310310
$S20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PAAg_AiJ1QAAg1_GF -> mangling_retroactive.test0(mangling_retroactive.Z<RetroactiveB.X, Swift.Int, RetroactiveB.Y>) -> ()
311+
_T0LiteralAByxGxd_tcfC ---> _T0LiteralAByxGxd_tcfC
312+
_T0XZ ---> _T0XZ

0 commit comments

Comments
 (0)