diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-23 15:48:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-23 15:48:41 +0000 |
commit | 195755ced7b7fb8b941e5d085fe5bd82f36f481e (patch) | |
tree | e00566901084dd31fb087411ada0d352020bf2c9 | |
parent | b3eac8932359bb3ce15f77f59fa46710175b42e5 (diff) |
Add a new setSuccessor method to terminator instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2730 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/InstrTypes.h | 1 | ||||
-rw-r--r-- | include/llvm/iTerminators.h | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 9852a32fda..f7d63d6a90 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -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); diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h index c5047bc6c3..482684aa8a 100644 --- a/include/llvm/iTerminators.h +++ b/include/llvm/iTerminators.h @@ -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: |