From 367cef7b7553def1f155752fba3dc297a967844b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 23 Aug 2003 23:14:37 +0000 Subject: [PATCH] Rename SwitchInst::dest_push_back -> addCase Add new removeCase method llvm-svn: 8088 --- include/llvm/iTerminators.h | 10 +++++++++- lib/VMCore/iSwitch.cpp | 14 +++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h index 16cfb19658a..434fe671d6d 100644 --- a/include/llvm/iTerminators.h +++ b/include/llvm/iTerminators.h @@ -147,7 +147,15 @@ public: return cast(Operands[1].get()); } - void dest_push_back(Constant *OnVal, BasicBlock *Dest); + /// addCase - Add an entry to the switch instruction... + /// + void addCase(Constant *OnVal, BasicBlock *Dest); + + /// removeCase - This method removes the specified successor from the switch + /// instruction. Note that this cannot be used to remove the default + /// destination (successor #0). + /// + void removeCase(unsigned idx); virtual const BasicBlock *getSuccessor(unsigned idx) const { assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!"); diff --git a/lib/VMCore/iSwitch.cpp b/lib/VMCore/iSwitch.cpp index a63adfdfcfd..e1cb00e3ad6 100644 --- a/lib/VMCore/iSwitch.cpp +++ b/lib/VMCore/iSwitch.cpp @@ -25,7 +25,19 @@ SwitchInst::SwitchInst(const SwitchInst &SI) } } -void SwitchInst::dest_push_back(Constant *OnVal, BasicBlock *Dest) { +/// addCase - Add an entry to the switch instruction... +/// +void SwitchInst::addCase(Constant *OnVal, BasicBlock *Dest) { Operands.push_back(Use((Value*)OnVal, this)); Operands.push_back(Use((Value*)Dest, this)); } + +/// removeCase - This method removes the specified successor from the switch +/// instruction. Note that this cannot be used to remove the default +/// destination (successor #0). +/// +void SwitchInst::removeCase(unsigned idx) { + assert(idx != 0 && "Cannot remove the default case!"); + assert(idx*2 < Operands.size() && "Successor index out of range!!!"); + Operands.erase(Operands.begin()+idx*2, Operands.begin()+(idx+1)*2); +}