@@ -67,8 +67,9 @@ void SwitchCaseFullExpr::unreachableExit() {
67
67
// ===----------------------------------------------------------------------===//
68
68
69
69
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 ();
72
73
using DeclBlockPair = std::pair<EnumElementDecl *, SILBasicBlock *>;
73
74
{
74
75
// TODO: We could store the data in CaseBB form and not have to do this.
@@ -90,20 +91,20 @@ void SwitchEnumBuilder::emit() && {
90
91
defaultBlockData ? defaultBlockData->count : ProfileCounter ();
91
92
ArrayRef<ProfileCounter> caseBlockCountsRef = caseBlockCounts;
92
93
if (isAddressOnly) {
93
- builder.createSwitchEnumAddr (loc, optional .getValue (), defaultBlock ,
94
- caseBlocks, caseBlockCountsRef,
94
+ builder.createSwitchEnumAddr (loc, subjectExprOperand .getValue (),
95
+ defaultBlock, caseBlocks, caseBlockCountsRef,
95
96
defaultBlockCount);
96
97
} else {
97
- if (optional .getType ().isAddress ()) {
98
+ if (subjectExprOperand .getType ().isAddress ()) {
98
99
// 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 );
101
102
} else {
102
- optional = builder.createLoadCopy (loc, optional );
103
+ subjectExprOperand = builder.createLoadCopy (loc, subjectExprOperand );
103
104
}
104
105
}
105
- builder.createSwitchEnum (loc, optional .forward (getSGF ()), defaultBlock ,
106
- caseBlocks, caseBlockCountsRef,
106
+ builder.createSwitchEnum (loc, subjectExprOperand .forward (getSGF ()),
107
+ defaultBlock, caseBlocks, caseBlockCountsRef,
107
108
defaultBlockCount);
108
109
}
109
110
}
@@ -121,9 +122,9 @@ void SwitchEnumBuilder::emit() && {
121
122
SwitchCaseFullExpr presentScope (builder.getSILGenFunction (),
122
123
CleanupLocation::get (loc), branchDest);
123
124
builder.emitBlock (defaultBlock);
124
- ManagedValue input = optional ;
125
+ ManagedValue input = subjectExprOperand ;
125
126
if (!isAddressOnly) {
126
- input = builder.createOwnedPhiArgument (optional .getType ());
127
+ input = builder.createOwnedPhiArgument (subjectExprOperand .getType ());
127
128
}
128
129
handler (input, std::move (presentScope));
129
130
builder.clearInsertionPoint ();
@@ -144,9 +145,9 @@ void SwitchEnumBuilder::emit() && {
144
145
ManagedValue input;
145
146
if (decl->hasAssociatedValues ()) {
146
147
// Pull the payload out if we have one.
147
- SILType inputType = optional .getType ().getEnumElementType (
148
+ SILType inputType = subjectExprOperand .getType ().getEnumElementType (
148
149
decl, builder.getModule (), builder.getFunction ());
149
- input = optional ;
150
+ input = subjectExprOperand ;
150
151
if (!isAddressOnly) {
151
152
input = builder.createOwnedPhiArgument (inputType);
152
153
}
@@ -167,9 +168,9 @@ void SwitchEnumBuilder::emit() && {
167
168
SwitchCaseFullExpr presentScope (builder.getSILGenFunction (),
168
169
CleanupLocation::get (loc), branchDest);
169
170
builder.emitBlock (defaultBlock);
170
- ManagedValue input = optional ;
171
+ ManagedValue input = subjectExprOperand ;
171
172
if (!isAddressOnly) {
172
- input = builder.createOwnedPhiArgument (optional .getType ());
173
+ input = builder.createOwnedPhiArgument (subjectExprOperand .getType ());
173
174
}
174
175
handler (input, std::move (presentScope));
175
176
builder.clearInsertionPoint ();
0 commit comments