Skip to content

Commit 2318f03

Browse files
authored
Merge pull request #38002 from al45tair/problem/63678141
[Demangler] Fix for crash in mangleSingleChildNode.
2 parents 00df48c + 4661deb commit 2318f03

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/Demangling/OldRemangler.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,19 @@ void Remangler::mangleProtocolSelfConformanceDescriptor(Node *node) {
581581
}
582582

583583
void Remangler::manglePartialApplyForwarder(Node *node) {
584-
Buffer << "PA__T";
585-
mangleSingleChildNode(node); // global
584+
Buffer << "PA";
585+
if (node->getNumChildren() == 1) {
586+
Buffer << "__T";
587+
mangleSingleChildNode(node); // global
588+
}
586589
}
587590

588591
void Remangler::manglePartialApplyObjCForwarder(Node *node) {
589-
Buffer << "PAo__T";
590-
mangleSingleChildNode(node); // global
592+
Buffer << "PAo";
593+
if (node->getNumChildren() == 1) {
594+
Buffer << "__T";
595+
mangleSingleChildNode(node); // global
596+
}
591597
}
592598

593599
void Remangler::mangleMergedFunction(Node *node) {

test/Demangle/remangle.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ RUN: diff %t.input %t.output
99
// CHECK: Swift.(Mystruct in _7B40D7ED6632C2BEA2CA3BFFD57E3435)
1010
RUN: swift-demangle -remangle-objc-rt '$ss8Mystruct33_7B40D7ED6632C2BEA2CA3BFFD57E3435LLV' | %FileCheck %s
1111

12+
// CHECK-OLD3: Swift.related decl 'H' for partial apply forwarder
13+
RUN: swift-demangle -remangle-objc-rt '$ssTALHP' | %FileCheck -check-prefix CHECK-OLD3 %s
14+
1215
// CHECK-GENERICEXT: Swift._ContiguousArrayStorage<(extension in Swift):Swift.FlattenSequence<StdlibCollectionUnittest.MinimalBidirectionalCollection<StdlibCollectionUnittest.MinimalBidirectionalCollection<Swift.Int>>>.Index>
1316
RUN: swift-demangle -remangle-objc-rt '$ss23_ContiguousArrayStorageCys15FlattenSequenceVsE5IndexVy24StdlibCollectionUnittest020MinimalBidirectionalH0VyAIySiGG_GGD' | %FileCheck -check-prefix CHECK-GENERICEXT %s
1417

0 commit comments

Comments
 (0)