@@ -67,8 +67,9 @@ void SwitchCaseFullExpr::unreachableExit() {
6767// ===----------------------------------------------------------------------===//
6868
6969void 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 ();
0 commit comments