Skip to content

[5.0] [Mangling] Give protocol-conformance-ref an operator. #21404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ Property behaviors are implemented using private protocol conformances.
::

concrete-protocol-conformance ::= type protocol-conformance-ref any-protocol-conformance-list 'HC'
protocol-conformance-ref ::= protocol module?
protocol-conformance-ref ::= protocol module? 'HP'

any-protocol-conformance ::= concrete-protocol-conformance
any-protocol-conformance ::= dependent-protocol-conformance
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Demangling/Demangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ class Demangler : public NodeFactory {
NodePointer getDependentGenericParamType(int depth, int index);
NodePointer demangleGenericParamIndex();
NodePointer popProtocolConformance();
NodePointer popProtocolConformanceRef();
NodePointer demangleProtocolConformanceRef();
NodePointer popAnyProtocolConformance();
NodePointer demangleConcreteProtocolConformance();
NodePointer popDependentProtocolConformance();
Expand Down
2 changes: 2 additions & 0 deletions lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,8 @@ void ASTMangler::appendProtocolConformanceRef(
// are global anyway.
if (isRetroactiveConformance(conformance))
appendModule(conformance->getDeclContext()->getParentModule());

appendOperator("HP");
}

/// Retrieve the index of the conformance requirement indicated by the
Expand Down
5 changes: 3 additions & 2 deletions lib/Demangling/Demangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ NodePointer Demangler::demangleOperator() {
case 'C': return demangleConcreteProtocolConformance();
case 'D': return demangleDependentProtocolConformanceRoot();
case 'I': return demangleDependentProtocolConformanceInherited();
case 'P': return demangleProtocolConformanceRef();
default:
pushBack();
pushBack();
Expand Down Expand Up @@ -1294,7 +1295,7 @@ NodePointer Demangler::popAnyProtocolConformance() {
});
}

NodePointer Demangler::popProtocolConformanceRef() {
NodePointer Demangler::demangleProtocolConformanceRef() {
NodePointer module = popModule();
NodePointer proto = popProtocol();
auto protocolConformanceRef =
Expand All @@ -1309,7 +1310,7 @@ NodePointer Demangler::popProtocolConformanceRef() {

NodePointer Demangler::demangleConcreteProtocolConformance() {
NodePointer conditionalConformanceList = popAnyProtocolConformanceList();
NodePointer conformanceRef = popProtocolConformanceRef();
NodePointer conformanceRef = popNode(Node::Kind::ProtocolConformanceRef);
NodePointer type = popNode(Node::Kind::Type);
return createWithChildren(Node::Kind::ConcreteProtocolConformance,
type, conformanceRef, conditionalConformanceList);
Expand Down
1 change: 1 addition & 0 deletions lib/Demangling/Remangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ void Remangler::mangleProtocolConformanceRef(Node *node) {
manglePureProtocol(node->getChild(0));
if (node->getNumChildren() > 1)
mangleChildNode(node, 1);
Buffer << "HP";
}

void Remangler::mangleConcreteProtocolConformance(Node *node) {
Expand Down
2 changes: 1 addition & 1 deletion test/Demangle/Inputs/manglings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ _T0So13GenericOptionas8HashableSCsACP9hashValueSivgTW ---> {T:} protocol witness
_T0So11CrappyColorVs16RawRepresentableSCMA ---> reflection metadata associated type descriptor __C.CrappyColor : Swift.RawRepresentable in __C_Synthesized
$S28protocol_conformance_records15NativeValueTypeVAA8RuncibleAAMc ---> protocol conformance descriptor for protocol_conformance_records.NativeValueType : protocol_conformance_records.Runcible in protocol_conformance_records
$SSC9SomeErrorLeVD ---> __C_Synthesized.related decl 'e' for SomeError
$s20mangling_retroactive5test1yyAA2Z2V5InnerVy12RetroactiveB1XV_AG1YVAI0F1A1PAAyHCg_AkL1QAAyHCg0_GF ---> mangling_retroactive.test1(mangling_retroactive.Z2<RetroactiveB.X>.Inner<RetroactiveB.Y>) -> ()
$s20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PAAHPyHCg_AiJ1QAAHPyHCg1_GF ---> mangling_retroactive.test0(mangling_retroactive.Z<RetroactiveB.X, Swift.Int, RetroactiveB.Y>) -> ()
_T0LiteralAByxGxd_tcfC ---> _T0LiteralAByxGxd_tcfC
_T0XZ ---> _T0XZ
_TTSf0os___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> function signature specialization <Arg[0] = Guaranteed To Owned and Exploded> of Swift._LegacyStringCore._invariantCheck() -> ()
Expand Down
6 changes: 3 additions & 3 deletions test/SILGen/mangling_retroactive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ struct Z<T: P, U: Hashable, V: Q> { }
extension X: P { } // retroactive
extension Y: Q { } // retroactive

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

struct Z2<T: P> {
struct Inner<V: Q> { }
}

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

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

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