Skip to content

Commit 72a9075

Browse files
committed
Return index from SwitchValueInst::getUniqueCaseForDestination
1 parent 07eb52a commit 72a9075

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/swift/SIL/SILInstruction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10224,7 +10224,7 @@ class SwitchValueInst final
1022410224
std::optional<unsigned> getUniqueCaseForDestination(SILBasicBlock *bb) const {
1022510225
for (unsigned i = 0; i < getNumCases(); ++i) {
1022610226
if (getCase(i).second == bb) {
10227-
return i + 1;
10227+
return i;
1022810228
}
1022910229
}
1023010230
return std::nullopt;

lib/SILOptimizer/Mandatory/YieldOnceCheck.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class YieldOnceCheck : public SILFunctionTransform {
496496
switchValue->getUniqueCaseForDestination(noYieldTarget);
497497
assert(caseNumberOpt.has_value());
498498

499-
auto caseNumber = caseNumberOpt.value();
499+
auto caseNumber = caseNumberOpt.value() + 1;
500500
diagnose(
501501
astCtx, enumCaseLoc, diag::switch_value_case_doesnt_yield,
502502
(Twine(caseNumber) + llvm::getOrdinalSuffix(caseNumber)).str());

0 commit comments

Comments
 (0)