Add a new setSuccessor method to terminator instructions
authorChris Lattner <sabre@nondot.org>
Thu, 23 May 2002 15:48:41 +0000 (15:48 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 23 May 2002 15:48:41 +0000 (15:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2730 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/InstrTypes.h
include/llvm/iTerminators.h

index 9852a32fdab04b68fe0ffd93440809e2ffe404ee..f7d63d6a9004963b0f1cef7c8d9676320a257708 100644 (file)
@@ -35,6 +35,7 @@ public:
   //
   virtual const BasicBlock *getSuccessor(unsigned idx) const = 0;
   virtual unsigned getNumSuccessors() const = 0;
+  virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) = 0;
 
   inline BasicBlock *getSuccessor(unsigned idx) {
     return (BasicBlock*)((const TerminatorInst *)this)->getSuccessor(idx);
index c5047bc6c3c338290c8edc422440c1693e2766d4..482684aa8ad12077540810c5e6f813561c82d96e 100644 (file)
@@ -52,6 +52,9 @@ public:
     assert(0 && "ReturnInst has no successors!");
     abort();
   }
+  virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
+    assert(0 && "ReturnInst has no successors!");
+  }
   virtual unsigned getNumSuccessors() const { return 0; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -105,6 +108,11 @@ public:
     return (BasicBlock*)((const BranchInst *)this)->getSuccessor(idx);
   }
 
+  virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
+    assert(idx < getNumSuccessors() && "Successor # out of range for Branch!");
+    Operands[idx] = (Value*)NewSucc;
+  }
+
   virtual unsigned getNumSuccessors() const { return 1+isConditional(); }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -156,6 +164,11 @@ public:
     return cast<BasicBlock>(Operands[idx*2+1].get());
   }
 
+  virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
+    assert(idx < getNumSuccessors() && "Successor # out of range for switch!");
+    Operands[idx*2+1] = (Value*)NewSucc;
+  }
+
   // getSuccessorValue - Return the value associated with the specified
   // successor.
   inline const Constant *getSuccessorValue(unsigned idx) const {
@@ -231,6 +244,11 @@ public:
     return i == 0 ? getNormalDest() : getExceptionalDest();
   }
 
+  virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
+    assert(idx < 2 && "Successor # out of range for invoke!");
+    Operands[idx+1] = (Value*)NewSucc;
+  }
+
   virtual unsigned getNumSuccessors() const { return 2; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast: