Skip to content

Commit 4ab61db

Browse files
authored
Merge pull request #21397 from DougGregor/mangle-protocol-conformance-ref-operator
[Mangling] Give protocol-conformance-ref an operator.
2 parents f6eeb3a + a39ea48 commit 4ab61db

File tree

9 files changed

+14
-10
lines changed

9 files changed

+14
-10
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
@@ -2282,6 +2282,8 @@ void ASTMangler::appendProtocolConformanceRef(
22822282
// are global anyway.
22832283
if (isRetroactiveConformance(conformance))
22842284
appendModule(conformance->getDeclContext()->getParentModule());
2285+
2286+
appendOperator("HP");
22852287
}
22862288

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

lib/AST/GenericSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#include "GenericSignatureBuilderImpl.h"
1718
#include "swift/AST/GenericSignature.h"
1819
#include "swift/AST/ASTContext.h"
1920
#include "swift/AST/GenericSignatureBuilder.h"
@@ -24,7 +25,6 @@
2425
#include "swift/AST/Types.h"
2526
#include "swift/Basic/STLExtras.h"
2627
#include <functional>
27-
#include "GenericSignatureBuilderImpl.h"
2828

2929
using namespace swift;
3030

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//
1717
//===----------------------------------------------------------------------===//
1818

19+
#include "GenericSignatureBuilderImpl.h"
1920
#include "swift/AST/GenericSignatureBuilder.h"
2021
#include "swift/AST/ASTContext.h"
2122
#include "swift/AST/DiagnosticsSema.h"
@@ -44,7 +45,6 @@
4445
#include "llvm/Support/raw_ostream.h"
4546
#include "llvm/Support/SaveAndRestore.h"
4647
#include <algorithm>
47-
#include "GenericSignatureBuilderImpl.h"
4848

4949
using namespace swift;
5050
using llvm::DenseMap;

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
@@ -1659,6 +1659,7 @@ void Remangler::mangleProtocolConformanceRef(Node *node) {
16591659
manglePureProtocol(node->getChild(0));
16601660
if (node->getNumChildren() > 1)
16611661
mangleChildNode(node, 1);
1662+
Buffer << "HP";
16621663
}
16631664

16641665
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)