Skip to content

Commit f25384d

Browse files
committed
fixup! [SandboxIR] Remove tight-coupling with LLVM's SwitchInst::CaseHandle
1 parent 66ad147 commit f25384d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

llvm/include/llvm/SandboxIR/Instruction.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,9 +1887,14 @@ class SwitchInst : public SingleLLVMInstructionImpl<llvm::SwitchInst> {
18871887
template <typename LLVMCaseItT, typename BlockT, typename ConstT>
18881888
class CaseItImpl;
18891889

1890+
// The template helps avoid code duplication for const and non-const
1891+
// CaseHandle variants.
18901892
template <typename LLVMCaseItT, typename BlockT, typename ConstT>
18911893
class CaseHandleImpl {
18921894
Context &Ctx;
1895+
// NOTE: We are not wrapping an LLVM CaseHande here because it is not
1896+
// default-constructible. Instead we are wrapping the LLVM CaseIt
1897+
// iterator, as we can always get an LLVM CaseHandle by de-referencing it.
18931898
LLVMCaseItT LLVMCaseIt;
18941899
template <typename T1, typename T2, typename T3> friend class CaseItImpl;
18951900

@@ -1908,6 +1913,8 @@ class SwitchInst : public SingleLLVMInstructionImpl<llvm::SwitchInst> {
19081913
}
19091914
};
19101915

1916+
// The template helps avoid code duplication for const and non-const CaseIt
1917+
// variants.
19111918
template <typename LLVMCaseItT, typename BlockT, typename ConstT>
19121919
class CaseItImpl : public iterator_facade_base<
19131920
CaseItImpl<LLVMCaseItT, BlockT, ConstT>,
@@ -1921,11 +1928,11 @@ class SwitchInst : public SingleLLVMInstructionImpl<llvm::SwitchInst> {
19211928
: CH(SI->getContext(), llvm::SwitchInst::CaseIt(
19221929
cast<llvm::SwitchInst>(SI->Val), CaseNum)) {}
19231930
CaseItImpl &operator+=(ptrdiff_t N) {
1924-
CH.LLVMCaseIt.operator+=(N);
1931+
CH.LLVMCaseIt += N;
19251932
return *this;
19261933
}
19271934
CaseItImpl &operator-=(ptrdiff_t N) {
1928-
CH.LLVMCaseIt.operator-=(N);
1935+
CH.LLVMCaseIt -= N;
19291936
return *this;
19301937
}
19311938
ptrdiff_t operator-(const CaseItImpl &Other) const {

0 commit comments

Comments
 (0)