From 65ad4ebbdd54360a30a324a9c37238dcc01530d2 Mon Sep 17 00:00:00 2001 From: Erik Eckstein Date: Wed, 7 Aug 2024 09:52:05 +0200 Subject: [PATCH] mangling: support inverse conformance requirement mangling in the old re-mangler This is needed to emit ObjC class names for classes inside generic types with e.g. non-copyable requirements. Fixes a compiler crash in IRGen. rdar://133333754 --- lib/Demangling/OldRemangler.cpp | 4 +++- test/IRGen/non-copyable-class-mangling.swift | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/IRGen/non-copyable-class-mangling.swift diff --git a/lib/Demangling/OldRemangler.cpp b/lib/Demangling/OldRemangler.cpp index dfc27c9b15dcb..d4b1932a47a35 100644 --- a/lib/Demangling/OldRemangler.cpp +++ b/lib/Demangling/OldRemangler.cpp @@ -3051,5 +3051,7 @@ ManglingError Remangler::mangleHasSymbolQuery(Node *node, unsigned depth) { ManglingError Remangler::mangleDependentGenericInverseConformanceRequirement(Node *node, unsigned depth) { - return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node); + DEMANGLER_ASSERT(node->getNumChildren() == 2, node); + RETURN_IF_ERROR(mangleConstrainedType(node->getChild(0), depth + 1)); + return mangle(node->getChild(1), depth + 1); } diff --git a/test/IRGen/non-copyable-class-mangling.swift b/test/IRGen/non-copyable-class-mangling.swift new file mode 100644 index 0000000000000..5319af6cd5fc6 --- /dev/null +++ b/test/IRGen/non-copyable-class-mangling.swift @@ -0,0 +1,11 @@ +// RUN: %target-swift-frontend %s -emit-ir -o /dev/null + +// Check that we don't crash on this in the old re-mangler. +// rdar://133333754 + +struct S where T: ~Copyable { + final class C { + let x = 27 + } +} +