Skip to content

Commit 371de68

Browse files
authored
Merge pull request #21404 from DougGregor/mangle-protocol-conformance-ref-operator-5.0
[5.0] [Mangling] Give protocol-conformance-ref an operator.
2 parents f4da38a + 5bffcfc commit 371de68

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

docs/ABI/Mangling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ Property behaviors are implemented using private protocol conformances.
633633
::
634634

635635
concrete-protocol-conformance ::= type protocol-conformance-ref any-protocol-conformance-list 'HC'
636-
protocol-conformance-ref ::= protocol module?
636+
protocol-conformance-ref ::= protocol module? 'HP'
637637

638638
any-protocol-conformance ::= concrete-protocol-conformance
639639
any-protocol-conformance ::= dependent-protocol-conformance

include/swift/Demangling/Demangler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ class Demangler : public NodeFactory {
458458
NodePointer getDependentGenericParamType(int depth, int index);
459459
NodePointer demangleGenericParamIndex();
460460
NodePointer popProtocolConformance();
461-
NodePointer popProtocolConformanceRef();
461+
NodePointer demangleProtocolConformanceRef();
462462
NodePointer popAnyProtocolConformance();
463463
NodePointer demangleConcreteProtocolConformance();
464464
NodePointer popDependentProtocolConformance();

lib/AST/ASTMangler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,6 +2293,8 @@ void ASTMangler::appendProtocolConformanceRef(
22932293
// are global anyway.
22942294
if (isRetroactiveConformance(conformance))
22952295
appendModule(conformance->getDeclContext()->getParentModule());
2296+
2297+
appendOperator("HP");
22962298
}
22972299

22982300
/// Retrieve the index of the conformance requirement indicated by the

lib/Demangling/Demangler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ NodePointer Demangler::demangleOperator() {
610610
case 'C': return demangleConcreteProtocolConformance();
611611
case 'D': return demangleDependentProtocolConformanceRoot();
612612
case 'I': return demangleDependentProtocolConformanceInherited();
613+
case 'P': return demangleProtocolConformanceRef();
613614
default:
614615
pushBack();
615616
pushBack();
@@ -1294,7 +1295,7 @@ NodePointer Demangler::popAnyProtocolConformance() {
12941295
});
12951296
}
12961297

1297-
NodePointer Demangler::popProtocolConformanceRef() {
1298+
NodePointer Demangler::demangleProtocolConformanceRef() {
12981299
NodePointer module = popModule();
12991300
NodePointer proto = popProtocol();
13001301
auto protocolConformanceRef =
@@ -1309,7 +1310,7 @@ NodePointer Demangler::popProtocolConformanceRef() {
13091310

13101311
NodePointer Demangler::demangleConcreteProtocolConformance() {
13111312
NodePointer conditionalConformanceList = popAnyProtocolConformanceList();
1312-
NodePointer conformanceRef = popProtocolConformanceRef();
1313+
NodePointer conformanceRef = popNode(Node::Kind::ProtocolConformanceRef);
13131314
NodePointer type = popNode(Node::Kind::Type);
13141315
return createWithChildren(Node::Kind::ConcreteProtocolConformance,
13151316
type, conformanceRef, conditionalConformanceList);

lib/Demangling/Remangler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ void Remangler::mangleProtocolConformanceRef(Node *node) {
16571657
manglePureProtocol(node->getChild(0));
16581658
if (node->getNumChildren() > 1)
16591659
mangleChildNode(node, 1);
1660+
Buffer << "HP";
16601661
}
16611662

16621663
void Remangler::mangleConcreteProtocolConformance(Node *node) {

test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ _T0So13GenericOptionas8HashableSCsACP9hashValueSivgTW ---> {T:} protocol witness
301301
_T0So11CrappyColorVs16RawRepresentableSCMA ---> reflection metadata associated type descriptor __C.CrappyColor : Swift.RawRepresentable in __C_Synthesized
302302
$S28protocol_conformance_records15NativeValueTypeVAA8RuncibleAAMc ---> protocol conformance descriptor for protocol_conformance_records.NativeValueType : protocol_conformance_records.Runcible in protocol_conformance_records
303303
$SSC9SomeErrorLeVD ---> __C_Synthesized.related decl 'e' for SomeError
304-
$s20mangling_retroactive5test1yyAA2Z2V5InnerVy12RetroactiveB1XV_AG1YVAI0F1A1PAAyHCg_AkL1QAAyHCg0_GF ---> mangling_retroactive.test1(mangling_retroactive.Z2<RetroactiveB.X>.Inner<RetroactiveB.Y>) -> ()
304+
$s20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PAAHPyHCg_AiJ1QAAHPyHCg1_GF ---> mangling_retroactive.test0(mangling_retroactive.Z<RetroactiveB.X, Swift.Int, RetroactiveB.Y>) -> ()
305305
_T0LiteralAByxGxd_tcfC ---> _T0LiteralAByxGxd_tcfC
306306
_T0XZ ---> _T0XZ
307307
_TTSf0os___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> function signature specialization <Arg[0] = Guaranteed To Owned and Exploded> of Swift._LegacyStringCore._invariantCheck() -> ()

test/SILGen/mangling_retroactive.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ struct Z<T: P, U: Hashable, V: Q> { }
1212
extension X: P { } // retroactive
1313
extension Y: Q { } // retroactive
1414

15-
// CHECK: sil hidden @$s20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PAAyHCg_AiJ1QAAyHCg1_GF
15+
// CHECK: sil hidden @$s20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PAAHPyHCg_AiJ1QAAHPyHCg1_GF
1616
func test0(_: Z<X, Int, Y>) { }
1717

1818
struct Z2<T: P> {
1919
struct Inner<V: Q> { }
2020
}
2121

22-
// CHECK: sil hidden @$s20mangling_retroactive5test1yyAA2Z2V5InnerVy12RetroactiveB1XV_AG1YVAI0F1A1PAAyHCg_AkL1QAAyHCg0_GF
22+
// CHECK: sil hidden @$s20mangling_retroactive5test1yyAA2Z2V5InnerVy12RetroactiveB1XV_AG1YVAI0F1A1PAAHPyHCg_AkL1QAAHPyHCg0_GF
2323
func test1(_: Z2<X>.Inner<Y>) { }
2424

2525
extension X: Hashable {
@@ -38,5 +38,5 @@ extension Z: Equatable where T: Hashable, V: Equatable {
3838
struct RequiresEquatable<T: Equatable> { }
3939

4040
// Conditional requirement involves retroactive conformances.
41-
// CHECK: sil hidden @$s20mangling_retroactive5test2yyAA17RequiresEquatableVyAA1ZVy12RetroactiveB1XVSiAG1YVAI0F1A1PAAyHCg_AkL1QAAyHCg1_GAOSQAISHAAyHC_AKSQAAyHCHCg_GF
41+
// CHECK: sil hidden @$s20mangling_retroactive5test2yyAA17RequiresEquatableVyAA1ZVy12RetroactiveB1XVSiAG1YVAI0F1A1PAAHPyHCg_AkL1QAAHPyHCg1_GAOSQHPAISHAAHPyHC_AKSQAAHPyHCHCg_GF
4242
func test2(_: RequiresEquatable<Z<X, Int, Y>>) { }

0 commit comments

Comments
 (0)