Skip to content

Commit 401eafa

Browse files
committed
[AST] NFC: Move getABIDecl onto ASTMangler
1 parent 6f14171 commit 401eafa

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,28 @@ class ASTMangler : public Mangler {
791791
const ValueDecl *forDecl);
792792

793793
void appendLifetimeDependence(LifetimeDependenceInfo info);
794+
795+
void gatherExistentialRequirements(SmallVectorImpl<Requirement> &reqs,
796+
ParameterizedProtocolType *PPT) const;
797+
798+
/// Extracts a list of inverse requirements from a PCT serving as the
799+
/// constraint type of an existential.
800+
void extractExistentialInverseRequirements(
801+
SmallVectorImpl<InverseRequirement> &inverses,
802+
ProtocolCompositionType *PCT) const;
803+
804+
template <typename DeclType>
805+
DeclType *getABIDecl(DeclType *D) const {
806+
if (!D)
807+
return nullptr;
808+
809+
auto abiRole = ABIRoleInfo(D);
810+
if (!abiRole.providesABI())
811+
return abiRole.getCounterpart();
812+
return nullptr;
813+
}
814+
815+
std::optional<SymbolicReferent> getABIDecl(SymbolicReferent ref) const;
794816
};
795817

796818
} // end namespace Mangle

lib/AST/ASTMangler.cpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,22 @@
6868
using namespace swift;
6969
using namespace swift::Mangle;
7070

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 {
8473
switch (ref.getKind()) {
85-
case ASTMangler::SymbolicReferent::NominalType:
74+
case SymbolicReferent::NominalType:
8675
if (auto abiTypeDecl = getABIDecl(ref.getNominalType())) {
87-
return ASTMangler::SymbolicReferent(abiTypeDecl);
76+
return SymbolicReferent(abiTypeDecl);
8877
}
8978
break;
9079

91-
case ASTMangler::SymbolicReferent::OpaqueType:
80+
case SymbolicReferent::OpaqueType:
9281
if (auto abiTypeDecl = getABIDecl(ref.getOpaqueType())) {
93-
return ASTMangler::SymbolicReferent(abiTypeDecl);
82+
return SymbolicReferent(abiTypeDecl);
9483
}
9584
break;
9685

97-
case ASTMangler::SymbolicReferent::ExtendedExistentialTypeShape:
86+
case SymbolicReferent::ExtendedExistentialTypeShape:
9887
// Do nothing; mangling will use the underlying ABI decls in the end.
9988
break;
10089
}
@@ -5329,18 +5318,18 @@ std::string ASTMangler::mangleAttachedMacroExpansion(
53295318
return finalize();
53305319
}
53315320

5332-
static void gatherExistentialRequirements(SmallVectorImpl<Requirement> &reqs,
5333-
ParameterizedProtocolType *PPT) {
5321+
void ASTMangler::gatherExistentialRequirements(
5322+
SmallVectorImpl<Requirement> &reqs, ParameterizedProtocolType *PPT) const {
53345323
auto protoTy = PPT->getBaseType();
53355324
ASSERT(!getABIDecl(protoTy->getDecl()) && "need to figure out behavior");
53365325
PPT->getRequirements(protoTy->getDecl()->getSelfInterfaceType(), reqs);
53375326
}
53385327

53395328
/// Extracts a list of inverse requirements from a PCT serving as the constraint
53405329
/// type of an existential.
5341-
static void extractExistentialInverseRequirements(
5342-
SmallVectorImpl<InverseRequirement> &inverses,
5343-
ProtocolCompositionType *PCT) {
5330+
void ASTMangler::extractExistentialInverseRequirements(
5331+
SmallVectorImpl<InverseRequirement> &inverses,
5332+
ProtocolCompositionType *PCT) const {
53445333
if (!PCT->hasInverse())
53455334
return;
53465335

0 commit comments

Comments
 (0)