aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-23 23:14:37 +0000
committerChris Lattner <sabre@nondot.org>2003-08-23 23:14:37 +0000
commit131d19f9c6752c90e9b2cde72b11164fd13850db (patch)
tree3d029d2a13be4f6200af2e68337732a46f81d968 /lib
parent44bb541c011bcae84759ed194ec7cb4139775fcb (diff)
Rename SwitchInst::dest_push_back -> addCase
Add new removeCase method git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/iSwitch.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/VMCore/iSwitch.cpp b/lib/VMCore/iSwitch.cpp
index a63adfdfcf..e1cb00e3ad 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);
+}