Skip to content

Commit bf6bb65

Browse files
authored
Merge pull request #76771 from hamishknight/rename-arg-interface-ty
[AST] NFC: Rename `getArgumentInterfaceType` -> `getPayloadInterfaceType`
2 parents f787e8f + 91ae5d6 commit bf6bb65

20 files changed

+54
-52
lines changed

include/swift/AST/Decl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8513,7 +8513,9 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
85138513
return hasName() ? getBaseIdentifier().str() : "_";
85148514
}
85158515

8516-
Type getArgumentInterfaceType() const;
8516+
/// Retrieve the payload type for the enum element, which is a tuple of the
8517+
/// associated values, or null if there are no associated values.
8518+
Type getPayloadInterfaceType() const;
85178519

85188520
void setParameterList(ParameterList *params);
85198521
ParameterList *getParameterList() const { return Params; }

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10642,7 +10642,7 @@ SourceRange EnumElementDecl::getSourceRange() const {
1064210642
return {getStartLoc(), getNameLoc()};
1064310643
}
1064410644

10645-
Type EnumElementDecl::getArgumentInterfaceType() const {
10645+
Type EnumElementDecl::getPayloadInterfaceType() const {
1064610646
if (!hasAssociatedValues())
1064710647
return nullptr;
1064810648

lib/IRGen/GenEnum.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ const {
231231

232232
// Empty payload addresses can be left undefined.
233233
if (payloadI == ElementsWithPayload.end()) {
234-
auto argTy = elt->getParentEnum()->mapTypeIntoContext(
235-
elt->getArgumentInterfaceType());
236-
return IGF.getTypeInfoForUnlowered(argTy)
234+
auto payloadTy = elt->getParentEnum()->mapTypeIntoContext(
235+
elt->getPayloadInterfaceType());
236+
return IGF.getTypeInfoForUnlowered(payloadTy)
237237
.getUndefAddress();
238238
}
239239

@@ -254,9 +254,9 @@ const {
254254

255255
// Empty payload addresses can be left undefined.
256256
if (payloadI == ElementsWithPayload.end()) {
257-
auto argTy = Case->getParentEnum()->mapTypeIntoContext(
258-
Case->getArgumentInterfaceType());
259-
return IGF.getTypeInfoForUnlowered(argTy)
257+
auto payloadTy = Case->getParentEnum()->mapTypeIntoContext(
258+
Case->getPayloadInterfaceType());
259+
return IGF.getTypeInfoForUnlowered(payloadTy)
260260
.getUndefAddress();
261261
}
262262

@@ -6463,10 +6463,10 @@ EnumImplStrategy::get(TypeConverter &TC, SILType type, EnumDecl *theEnum) {
64636463
// strategy. If the abstract layout of the enum is dependent on generic
64646464
// parameters, then we additionally need to constrain any layout
64656465
// optimizations we perform to things that are reproducible by the runtime.
6466-
Type origArgType = elt->getArgumentInterfaceType();
6467-
origArgType = theEnum->mapTypeIntoContext(origArgType);
6466+
Type origPayloadType = elt->getPayloadInterfaceType();
6467+
origPayloadType = theEnum->mapTypeIntoContext(origPayloadType);
64686468

6469-
auto origArgLoweredTy = TC.IGM.getLoweredType(origArgType);
6469+
auto origArgLoweredTy = TC.IGM.getLoweredType(origPayloadType);
64706470
auto *origArgTI = &TC.getCompleteTypeInfo(origArgLoweredTy.getASTType());
64716471

64726472
// If the unsubstituted argument contains a generic parameter type, or

lib/IRGen/GenReflection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
942942
flags.setIsIndirectCase();
943943

944944
Type interfaceType = decl->isAvailableDuringLowering()
945-
? decl->getArgumentInterfaceType()
945+
? decl->getPayloadInterfaceType()
946946
: nullptr;
947947

948948
addField(flags, interfaceType, decl->getBaseIdentifier().str());

lib/IRGen/GenType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2484,7 +2484,7 @@ namespace {
24842484
if (!elt->hasAssociatedValues() || elt->isIndirect())
24852485
continue;
24862486

2487-
if (visit(elt->getArgumentInterfaceType()->getCanonicalType()))
2487+
if (visit(elt->getPayloadInterfaceType()->getCanonicalType()))
24882488
return true;
24892489
}
24902490
return false;

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,11 +1358,11 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
13581358
SmallVector<llvm::Metadata *, 16> Elements;
13591359
for (auto *ElemDecl : Decl->getAllElements()) {
13601360
std::optional<CompletedDebugTypeInfo> ElemDbgTy;
1361-
if (auto ArgTy = ElemDecl->getArgumentInterfaceType()) {
1361+
if (auto PayloadTy = ElemDecl->getPayloadInterfaceType()) {
13621362
// A variant case which carries a payload.
1363-
ArgTy = ElemDecl->getParentEnum()->mapTypeIntoContext(ArgTy);
1364-
auto &TI = IGM.getTypeInfoForUnlowered(ArgTy);
1365-
ElemDbgTy = CompletedDebugTypeInfo::getFromTypeInfo(ArgTy, TI, IGM);
1363+
PayloadTy = ElemDecl->getParentEnum()->mapTypeIntoContext(PayloadTy);
1364+
auto &TI = IGM.getTypeInfoForUnlowered(PayloadTy);
1365+
ElemDbgTy = CompletedDebugTypeInfo::getFromTypeInfo(PayloadTy, TI, IGM);
13661366
if (!ElemDbgTy) {
13671367
// Without complete type info we can only create a forward decl.
13681368
return DBuilder.createForwardDecl(
@@ -1434,11 +1434,11 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
14341434
SmallVector<llvm::Metadata *, 16> Elements;
14351435
for (auto *ElemDecl : Decl->getAllElements()) {
14361436
std::optional<DebugTypeInfo> ElemDbgTy;
1437-
if (auto ArgTy = ElemDecl->getArgumentInterfaceType()) {
1437+
if (auto PayloadTy = ElemDecl->getPayloadInterfaceType()) {
14381438
// A variant case which carries a payload.
1439-
ArgTy = ElemDecl->getParentEnum()->mapTypeIntoContext(ArgTy);
1439+
PayloadTy = ElemDecl->getParentEnum()->mapTypeIntoContext(PayloadTy);
14401440
ElemDbgTy = DebugTypeInfo::getFromTypeInfo(
1441-
ArgTy, IGM.getTypeInfoForUnlowered(ArgTy), IGM);
1441+
PayloadTy, IGM.getTypeInfoForUnlowered(PayloadTy), IGM);
14421442
unsigned Offset = 0;
14431443
auto MTy =
14441444
createMemberType(*ElemDbgTy, ElemDecl->getBaseIdentifier().str(),

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ AbstractionPattern TypeConverter::getAbstractionPattern(EnumElementDecl *decl) {
120120
auto sig = decl->getParentEnum()
121121
->getGenericSignatureOfContext()
122122
.getCanonicalSignature();
123-
auto type = sig.getReducedType(decl->getArgumentInterfaceType());
123+
auto type = sig.getReducedType(decl->getPayloadInterfaceType());
124124

125125
return AbstractionPattern(sig, type);
126126
}

lib/SIL/IR/SILType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ SILType SILType::getEnumElementType(EnumElementDecl *elt, TypeConverter &TC,
414414
addFieldSubstitutionsIfNeeded(TC, *this, elt, origEltType);
415415

416416
auto substEltTy = getASTType()->getTypeOfMember(
417-
elt, elt->getArgumentInterfaceType());
417+
elt, elt->getPayloadInterfaceType());
418418
auto loweredTy = TC.getLoweredRValueType(
419419
context, TC.getAbstractionPattern(elt), substEltTy);
420420

lib/SIL/IR/TypeLowering.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,11 +2559,11 @@ namespace {
25592559
}
25602560

25612561
auto substEltType =
2562-
elt->getArgumentInterfaceType().subst(subMap)
2562+
elt->getPayloadInterfaceType().subst(subMap)
25632563
->getCanonicalType();
25642564

25652565
auto origEltType = origType.unsafeGetSubstFieldType(elt,
2566-
elt->getArgumentInterfaceType()
2566+
elt->getPayloadInterfaceType()
25672567
->getReducedType(D->getGenericSignature()),
25682568
subMap);
25692569
properties.addSubobject(classifyType(origEltType, substEltType,
@@ -2968,11 +2968,11 @@ bool TypeConverter::visitAggregateLeaves(
29682968
// TODO: Callback for indirect elements.
29692969
if (element->isIndirect())
29702970
continue;
2971-
auto substElementType = element->getArgumentInterfaceType()
2971+
auto substElementType = element->getPayloadInterfaceType()
29722972
.subst(subMap)
29732973
->getCanonicalType();
29742974
auto origElementTy = origTy.unsafeGetSubstFieldType(
2975-
element, element->getArgumentInterfaceType()->getReducedType(
2975+
element, element->getPayloadInterfaceType()->getReducedType(
29762976
decl->getGenericSignature()), subMap);
29772977

29782978
insertIntoWorklist(substElementType, origElementTy, element,
@@ -5028,7 +5028,7 @@ CanSILBoxType TypeConverter::getBoxTypeForEnumElement(
50285028
enumDecl->getGenericSignature());
50295029

50305030
if (boxSignature == CanGenericSignature()) {
5031-
auto eltIntfTy = elt->getArgumentInterfaceType();
5031+
auto eltIntfTy = elt->getPayloadInterfaceType();
50325032
auto boxVarTy = getLoweredRValueType(context, eltIntfTy);
50335033
auto layout = SILLayout::get(C, nullptr, SILField(boxVarTy, true),
50345034
/*captures generics*/ false);
@@ -5039,7 +5039,7 @@ CanSILBoxType TypeConverter::getBoxTypeForEnumElement(
50395039
auto boundEnum = enumType.getRawASTType();
50405040

50415041
// Lower the enum element's argument in the box's context.
5042-
auto eltIntfTy = elt->getArgumentInterfaceType();
5042+
auto eltIntfTy = elt->getPayloadInterfaceType();
50435043

50445044
auto boxVarTy = getLoweredRValueType(context,
50455045
getAbstractionPattern(elt), eltIntfTy);

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,7 +3620,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
36203620
require(ud, "UncheckedEnumData must take an enum operand");
36213621
require(UI->getElement()->getParentEnum() == ud,
36223622
"UncheckedEnumData case must be a case of the enum operand type");
3623-
require(UI->getElement()->getArgumentInterfaceType(),
3623+
require(UI->getElement()->getPayloadInterfaceType(),
36243624
"UncheckedEnumData case must have a data type");
36253625
require(UI->getOperand()->getType().isObject(),
36263626
"UncheckedEnumData must take an address operand");
@@ -3642,7 +3642,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
36423642
require(ud, "UncheckedTakeEnumDataAddrInst must take an enum operand");
36433643
require(UI->getElement()->getParentEnum() == ud,
36443644
"UncheckedTakeEnumDataAddrInst case must be a case of the enum operand type");
3645-
require(UI->getElement()->getArgumentInterfaceType(),
3645+
require(UI->getElement()->getPayloadInterfaceType(),
36463646
"UncheckedTakeEnumDataAddrInst case must have a data type");
36473647
require(UI->getOperand()->getType().isAddress(),
36483648
"UncheckedTakeEnumDataAddrInst must take an address operand");

0 commit comments

Comments
 (0)