IR: Avoid duplication of SwitchInst::findCaseValue(), NFC

Change the non-const version of findCaseValue() to forward to the const
version.
This commit is contained in:
Duncan P. N. Exon Smith 2021-11-11 18:20:52 -08:00
parent de2fed6152
commit 8b3e1adf2b
1 changed files with 3 additions and 6 deletions

View File

@ -3515,12 +3515,9 @@ public:
/// default case iterator to indicate that it is handled by the default
/// handler.
CaseIt findCaseValue(const ConstantInt *C) {
CaseIt I = llvm::find_if(
cases(), [C](CaseHandle &Case) { return Case.getCaseValue() == C; });
if (I != case_end())
return I;
return case_default();
return CaseIt(
this,
const_cast<const SwitchInst *>(this)->findCaseValue(C)->getCaseIndex());
}
ConstCaseIt findCaseValue(const ConstantInt *C) const {
ConstCaseIt I = llvm::find_if(cases(), [C](ConstCaseHandle &Case) {