@@ -922,8 +922,6 @@ void ASTMangler::appendSymbolKind(SymbolKind SKind) {
922922 case SymbolKind::DistributedThunk: return appendOperator (" TE" );
923923 case SymbolKind::DistributedAccessor: return appendOperator (" TF" );
924924 case SymbolKind::AccessibleFunctionRecord: return appendOperator (" HF" );
925- case SymbolKind::AccessibleProtocolRequirementFunctionRecord:
926- return appendOperator (" HpF" );
927925 case SymbolKind::BackDeploymentThunk: return appendOperator (" Twb" );
928926 case SymbolKind::BackDeploymentFallback: return appendOperator (" TwB" );
929927 case SymbolKind::HasSymbolQuery: return appendOperator (" TwS" );
@@ -3904,11 +3902,13 @@ ASTMangler::mangleOpaqueTypeDescriptorRecord(const OpaqueTypeDecl *decl) {
39043902 return finalize ();
39053903}
39063904
3907- std::string ASTMangler::mangleDistributedThunk (const AbstractFunctionDecl *thunk) {
3905+ void ASTMangler::appendDistributedThunk (
3906+ const AbstractFunctionDecl *thunk, bool asReference) {
39083907 // Marker protocols cannot be checked at runtime, so there is no point
39093908 // in recording them for distributed thunks.
39103909 llvm::SaveAndRestore<bool > savedAllowMarkerProtocols (AllowMarkerProtocols,
39113910 false );
3911+ // TODO: add a flag to skip class/struct information from parameter types
39123912
39133913 // Since computed property SILDeclRef's refer to the "originator"
39143914 // of the thunk, we need to mangle distributed thunks of accessors
@@ -3931,8 +3931,52 @@ std::string ASTMangler::mangleDistributedThunk(const AbstractFunctionDecl *thunk
39313931 thunk = storage->getDistributedThunk ();
39323932 assert (thunk);
39333933 }
3934+ assert (isa<AbstractFunctionDecl>(thunk) &&
3935+ " distributed thunk to mangle must be function decl" );
3936+ assert (thunk->getContextKind () == DeclContextKind::AbstractFunctionDecl);
3937+
3938+ auto inProtocolExtensionMangleAsReference =
3939+ [&thunk, asReference]() -> ProtocolDecl * {
3940+ if (!asReference) {
3941+ return nullptr ;
3942+ }
3943+
3944+ if (auto extension = dyn_cast<ExtensionDecl>(thunk->getDeclContext ())) {
3945+ return dyn_cast_or_null<ProtocolDecl>(extension->getExtendedNominal ());
3946+ }
3947+ return nullptr ;
3948+ };
3949+
3950+ if (auto type = inProtocolExtensionMangleAsReference ()) {
3951+ appendContext (type->getDeclContext (), thunk->getAlternateModuleName ());
3952+ auto baseName = type->getBaseName ();
3953+ appendIdentifier (Twine (" $" , baseName.getIdentifier ().str ()).str ());
3954+ appendOperator (" C" ); // necessary for roundtrip, though we don't use it
3955+ } else {
3956+ appendContextOf (thunk);
3957+ }
39343958
3935- return mangleEntity (thunk, SymbolKind::DistributedThunk);
3959+ appendIdentifier (thunk->getBaseName ().getIdentifier ().str ());
3960+ appendDeclType (thunk, FunctionMangling);
3961+ appendOperator (" F" );
3962+ appendSymbolKind (SymbolKind::DistributedThunk);
3963+ }
3964+
3965+ std::string ASTMangler::mangleDistributedThunkRef (const AbstractFunctionDecl *thunk) {
3966+ beginMangling ();
3967+ appendDistributedThunk (thunk, /* asReference=*/ true );
3968+ return finalize ();
3969+ }
3970+ std::string ASTMangler::mangleDistributedThunkRecord (const AbstractFunctionDecl *thunk) {
3971+ beginMangling ();
3972+ appendDistributedThunk (thunk, /* asReference=*/ true );
3973+ appendSymbolKind (SymbolKind::AccessibleFunctionRecord);
3974+ return finalize ();
3975+ }
3976+ std::string ASTMangler::mangleDistributedThunk (const AbstractFunctionDecl *thunk) {
3977+ beginMangling ();
3978+ appendDistributedThunk (thunk, /* asReference=*/ false );
3979+ return finalize ();
39363980}
39373981
39383982void ASTMangler::appendMacroExpansionContext (
0 commit comments