|
68 | 68 | using namespace swift; |
69 | 69 | using namespace swift::Mangle; |
70 | 70 |
|
71 | | -template<typename DeclType> |
72 | | -static DeclType *getABIDecl(DeclType *D) { |
73 | | - if (!D) |
74 | | - return nullptr; |
75 | | - |
76 | | - auto abiRole = ABIRoleInfo(D); |
77 | | - if (!abiRole.providesABI()) |
78 | | - return abiRole.getCounterpart(); |
79 | | - return nullptr; |
80 | | -} |
81 | | - |
82 | | -static std::optional<ASTMangler::SymbolicReferent> |
83 | | -getABIDecl(ASTMangler::SymbolicReferent ref) { |
| 71 | +std::optional<ASTMangler::SymbolicReferent> |
| 72 | +ASTMangler::getABIDecl(SymbolicReferent ref) const { |
84 | 73 | switch (ref.getKind()) { |
85 | | - case ASTMangler::SymbolicReferent::NominalType: |
| 74 | + case SymbolicReferent::NominalType: |
86 | 75 | if (auto abiTypeDecl = getABIDecl(ref.getNominalType())) { |
87 | | - return ASTMangler::SymbolicReferent(abiTypeDecl); |
| 76 | + return SymbolicReferent(abiTypeDecl); |
88 | 77 | } |
89 | 78 | break; |
90 | 79 |
|
91 | | - case ASTMangler::SymbolicReferent::OpaqueType: |
| 80 | + case SymbolicReferent::OpaqueType: |
92 | 81 | if (auto abiTypeDecl = getABIDecl(ref.getOpaqueType())) { |
93 | | - return ASTMangler::SymbolicReferent(abiTypeDecl); |
| 82 | + return SymbolicReferent(abiTypeDecl); |
94 | 83 | } |
95 | 84 | break; |
96 | 85 |
|
97 | | - case ASTMangler::SymbolicReferent::ExtendedExistentialTypeShape: |
| 86 | + case SymbolicReferent::ExtendedExistentialTypeShape: |
98 | 87 | // Do nothing; mangling will use the underlying ABI decls in the end. |
99 | 88 | break; |
100 | 89 | } |
@@ -969,8 +958,6 @@ std::string ASTMangler::mangleTypeAsContextUSR(const NominalTypeDecl *type) { |
969 | 958 | } |
970 | 959 |
|
971 | 960 | std::string ASTMangler::mangleTypeAsUSR(Type Ty) { |
972 | | - DWARFMangling = true; |
973 | | - RespectOriginallyDefinedIn = false; |
974 | 961 | beginMangling(); |
975 | 962 |
|
976 | 963 | Ty = getTypeForDWARFMangling(Ty); |
@@ -1006,42 +993,34 @@ void ASTMangler::appendAnyDecl(const ValueDecl *Decl) { |
1006 | 993 | } |
1007 | 994 | } |
1008 | 995 |
|
1009 | | -std::string |
1010 | | -ASTMangler::mangleAnyDecl(const ValueDecl *Decl, |
1011 | | - bool prefix, |
1012 | | - bool respectOriginallyDefinedIn) { |
| 996 | +std::string ASTMangler::mangleAnyDecl(const ValueDecl *decl, bool addPrefix) { |
1013 | 997 | DWARFMangling = true; |
1014 | | - RespectOriginallyDefinedIn = respectOriginallyDefinedIn; |
1015 | | - if (prefix) { |
| 998 | + if (addPrefix) { |
1016 | 999 | beginMangling(); |
1017 | 1000 | } else { |
1018 | 1001 | beginManglingWithoutPrefix(); |
1019 | 1002 | } |
1020 | 1003 | llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true); |
1021 | 1004 |
|
1022 | | - appendAnyDecl(Decl); |
| 1005 | + appendAnyDecl(decl); |
1023 | 1006 |
|
1024 | 1007 | // We have a custom prefix, so finalize() won't verify for us. If we're not |
1025 | 1008 | // in invalid code (coming from an IDE caller) verify manually. |
1026 | | - if (CONDITIONAL_ASSERT_enabled() && !prefix && !Decl->isInvalid()) |
| 1009 | + if (CONDITIONAL_ASSERT_enabled() && !addPrefix && !decl->isInvalid()) |
1027 | 1010 | verify(Storage.str(), Flavor); |
1028 | 1011 | return finalize(); |
1029 | 1012 | } |
1030 | 1013 |
|
1031 | | -std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl, |
1032 | | - StringRef USRPrefix) { |
1033 | | - llvm::SaveAndRestore<bool> respectOriginallyDefinedInRAII( |
1034 | | - RespectOriginallyDefinedIn, false); |
1035 | | - return (llvm::Twine(USRPrefix) + mangleAnyDecl(Decl, false)).str(); |
| 1014 | +std::string ASTMangler::mangleDeclWithPrefix(const ValueDecl *decl, |
| 1015 | + StringRef prefix) { |
| 1016 | + return (llvm::Twine(prefix) + mangleAnyDecl(decl, /*addPrefix*/ false)).str(); |
1036 | 1017 | } |
1037 | 1018 |
|
1038 | 1019 | std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind, |
1039 | 1020 | const AbstractStorageDecl *decl, |
1040 | 1021 | StringRef USRPrefix, |
1041 | 1022 | bool isStatic) { |
1042 | 1023 | beginManglingWithoutPrefix(); |
1043 | | - llvm::SaveAndRestore<bool> respectOriginallyDefinedInRAII( |
1044 | | - RespectOriginallyDefinedIn, false); |
1045 | 1024 | llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true); |
1046 | 1025 | Buffer << USRPrefix; |
1047 | 1026 | appendAccessorEntity(getCodeForAccessorKind(kind), decl, isStatic); |
@@ -5329,18 +5308,18 @@ std::string ASTMangler::mangleAttachedMacroExpansion( |
5329 | 5308 | return finalize(); |
5330 | 5309 | } |
5331 | 5310 |
|
5332 | | -static void gatherExistentialRequirements(SmallVectorImpl<Requirement> &reqs, |
5333 | | - ParameterizedProtocolType *PPT) { |
| 5311 | +void ASTMangler::gatherExistentialRequirements( |
| 5312 | + SmallVectorImpl<Requirement> &reqs, ParameterizedProtocolType *PPT) const { |
5334 | 5313 | auto protoTy = PPT->getBaseType(); |
5335 | 5314 | ASSERT(!getABIDecl(protoTy->getDecl()) && "need to figure out behavior"); |
5336 | 5315 | PPT->getRequirements(protoTy->getDecl()->getSelfInterfaceType(), reqs); |
5337 | 5316 | } |
5338 | 5317 |
|
5339 | 5318 | /// Extracts a list of inverse requirements from a PCT serving as the constraint |
5340 | 5319 | /// type of an existential. |
5341 | | -static void extractExistentialInverseRequirements( |
5342 | | - SmallVectorImpl<InverseRequirement> &inverses, |
5343 | | - ProtocolCompositionType *PCT) { |
| 5320 | +void ASTMangler::extractExistentialInverseRequirements( |
| 5321 | + SmallVectorImpl<InverseRequirement> &inverses, |
| 5322 | + ProtocolCompositionType *PCT) const { |
5344 | 5323 | if (!PCT->hasInverse()) |
5345 | 5324 | return; |
5346 | 5325 |
|
|
0 commit comments