Skip to content

Commit 063929b

Browse files
committed
Demangler: fix a crash when re-mangling retroactive conformances
If there are multiple retroactive conformances in the mangling tree, they are put under a TypeList node. This case was not handled by the re-mangler. The crash shows up in an assert-build of the compiler, because the re-mangler is used for mangling verification. rdar://problem/68467435
1 parent 9fb7769 commit 063929b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/Demangling/Remangler.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,8 +1487,14 @@ void Remangler::mangleImplFunctionType(Node *node) {
14871487
mangle(PatternSubs->getChild(0));
14881488
Buffer << 'y';
14891489
mangleChildNodes(PatternSubs->getChild(1));
1490-
if (PatternSubs->getNumChildren() >= 3)
1491-
mangleRetroactiveConformance(PatternSubs->getChild(2));
1490+
if (PatternSubs->getNumChildren() >= 3) {
1491+
NodePointer retroactiveConf = PatternSubs->getChild(2);
1492+
if (retroactiveConf->getKind() == Node::Kind::TypeList) {
1493+
mangleChildNodes(retroactiveConf);
1494+
} else {
1495+
mangleRetroactiveConformance(retroactiveConf);
1496+
}
1497+
}
14921498
}
14931499

14941500
Buffer << 'I';

test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ _$S3BBBBi0602365061_ ---> _$S3BBBBi0602365061_
330330
_$S3BBBBv0602365061_ ---> _$S3BBBBv0602365061_
331331
_T0lxxxmmmTk ---> _T0lxxxmmmTk
332332
_TtCF4test11doNotCrash1FT_QuL_8MyClass1 ---> MyClass1 #1 in test.doNotCrash1() -> some
333+
$s3Bar3FooVAA5DrinkVyxGs5Error_pSeRzSERzlyShy4AbcdAHO6MemberVGALSeHPAKSeAAyHC_HCg_ALSEHPAKSEAAyHC_HCg0_Iseggozo_SgWOe ---> outlined consume of @escaping @callee_guaranteed @substituted <A where A: Swift.Decodable, A: Swift.Encodable> (@guaranteed Bar.Foo) -> (@owned Bar.Drink<A>, @error @owned Swift.Error) for <Swift.Set<Abcd.Abcd.Member>>?
333334
$s4Test5ProtoP8IteratorV10collectionAEy_qd__Gqd___tcfc ---> Test.Proto.Iterator.init(collection: A1) -> Test.Proto.Iterator<A1>
334335
$s4test3fooV4blahyAA1SV1fQryFQOy_Qo_AHF ---> test.foo.blah(<<opaque return type of test.S.f() -> some>>.0) -> <<opaque return type of test.S.f() -> some>>.0
335336
$S3nix8MystructV1xACyxGx_tcfc7MyaliasL_ayx__GD ---> Myalias #1 in nix.Mystruct<A>.init(x: A) -> nix.Mystruct<A>

0 commit comments

Comments
 (0)