Skip to content

Commit ae25ceb

Browse files
authored
Merge pull request swiftlang#34982 from varungandhi-apple/vg-SwitchEnumBuilder-rename-field
2 parents 72fc06c + 4195859 commit ae25ceb

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

lib/SILGen/SwitchEnumBuilder.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ void SwitchCaseFullExpr::unreachableExit() {
6767
//===----------------------------------------------------------------------===//
6868

6969
void SwitchEnumBuilder::emit() && {
70-
bool isAddressOnly = optional.getType().isAddressOnly(builder.getFunction()) &&
71-
getSGF().silConv.useLoweredAddresses();
70+
bool isAddressOnly =
71+
subjectExprOperand.getType().isAddressOnly(builder.getFunction()) &&
72+
getSGF().silConv.useLoweredAddresses();
7273
using DeclBlockPair = std::pair<EnumElementDecl *, SILBasicBlock *>;
7374
{
7475
// TODO: We could store the data in CaseBB form and not have to do this.
@@ -90,20 +91,20 @@ void SwitchEnumBuilder::emit() && {
9091
defaultBlockData ? defaultBlockData->count : ProfileCounter();
9192
ArrayRef<ProfileCounter> caseBlockCountsRef = caseBlockCounts;
9293
if (isAddressOnly) {
93-
builder.createSwitchEnumAddr(loc, optional.getValue(), defaultBlock,
94-
caseBlocks, caseBlockCountsRef,
94+
builder.createSwitchEnumAddr(loc, subjectExprOperand.getValue(),
95+
defaultBlock, caseBlocks, caseBlockCountsRef,
9596
defaultBlockCount);
9697
} else {
97-
if (optional.getType().isAddress()) {
98+
if (subjectExprOperand.getType().isAddress()) {
9899
// TODO: Refactor this into a maybe load.
99-
if (optional.hasCleanup()) {
100-
optional = builder.createLoadTake(loc, optional);
100+
if (subjectExprOperand.hasCleanup()) {
101+
subjectExprOperand = builder.createLoadTake(loc, subjectExprOperand);
101102
} else {
102-
optional = builder.createLoadCopy(loc, optional);
103+
subjectExprOperand = builder.createLoadCopy(loc, subjectExprOperand);
103104
}
104105
}
105-
builder.createSwitchEnum(loc, optional.forward(getSGF()), defaultBlock,
106-
caseBlocks, caseBlockCountsRef,
106+
builder.createSwitchEnum(loc, subjectExprOperand.forward(getSGF()),
107+
defaultBlock, caseBlocks, caseBlockCountsRef,
107108
defaultBlockCount);
108109
}
109110
}
@@ -121,9 +122,9 @@ void SwitchEnumBuilder::emit() && {
121122
SwitchCaseFullExpr presentScope(builder.getSILGenFunction(),
122123
CleanupLocation::get(loc), branchDest);
123124
builder.emitBlock(defaultBlock);
124-
ManagedValue input = optional;
125+
ManagedValue input = subjectExprOperand;
125126
if (!isAddressOnly) {
126-
input = builder.createOwnedPhiArgument(optional.getType());
127+
input = builder.createOwnedPhiArgument(subjectExprOperand.getType());
127128
}
128129
handler(input, std::move(presentScope));
129130
builder.clearInsertionPoint();
@@ -144,9 +145,9 @@ void SwitchEnumBuilder::emit() && {
144145
ManagedValue input;
145146
if (decl->hasAssociatedValues()) {
146147
// Pull the payload out if we have one.
147-
SILType inputType = optional.getType().getEnumElementType(
148+
SILType inputType = subjectExprOperand.getType().getEnumElementType(
148149
decl, builder.getModule(), builder.getFunction());
149-
input = optional;
150+
input = subjectExprOperand;
150151
if (!isAddressOnly) {
151152
input = builder.createOwnedPhiArgument(inputType);
152153
}
@@ -167,9 +168,9 @@ void SwitchEnumBuilder::emit() && {
167168
SwitchCaseFullExpr presentScope(builder.getSILGenFunction(),
168169
CleanupLocation::get(loc), branchDest);
169170
builder.emitBlock(defaultBlock);
170-
ManagedValue input = optional;
171+
ManagedValue input = subjectExprOperand;
171172
if (!isAddressOnly) {
172-
input = builder.createOwnedPhiArgument(optional.getType());
173+
input = builder.createOwnedPhiArgument(subjectExprOperand.getType());
173174
}
174175
handler(input, std::move(presentScope));
175176
builder.clearInsertionPoint();

lib/SILGen/SwitchEnumBuilder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ class SwitchEnumBuilder {
133133

134134
SILGenBuilder &builder;
135135
SILLocation loc;
136-
ManagedValue optional;
136+
ManagedValue subjectExprOperand;
137137
llvm::Optional<DefaultCaseData> defaultBlockData;
138138
llvm::SmallVector<NormalCaseData, 8> caseDataArray;
139139

140140
public:
141141
SwitchEnumBuilder(SILGenBuilder &builder, SILLocation loc,
142-
ManagedValue optional)
143-
: builder(builder), loc(loc), optional(optional) {}
142+
ManagedValue subjectExprOperand)
143+
: builder(builder), loc(loc), subjectExprOperand(subjectExprOperand) {}
144144

145145
void addDefaultCase(
146146
SILBasicBlock *defaultBlock, SwitchCaseBranchDest branchDest,

0 commit comments

Comments
 (0)