add a new insertAfter method, patch by Tom Jablin!
authorChris Lattner <sabre@nondot.org>
Tue, 13 Jan 2009 07:43:51 +0000 (07:43 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Jan 2009 07:43:51 +0000 (07:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62158 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/ilist.h
include/llvm/Instruction.h
lib/VMCore/Instruction.cpp

index bd2fd0df87199828d7225fef5866a81dffd558e4..6619f0a71ebe56a46a9b5369950d73898f6ea8d4 100644 (file)
@@ -384,6 +384,13 @@ public:
     return New;
   }
 
+  iterator insertAfter(iterator where, NodeTy *New) {
+    if (empty()) 
+      return insert(begin(), New);
+    else
+      return insert(++where, New);
+  }
+
   NodeTy *remove(iterator &IT) {
     assert(IT != end() && "Cannot remove end of list!");
     NodeTy *Node = &*IT;
index 9a7f769a94f9c5bb8fd3f13aadac6bc73435ffb7..a9cc000a25e37145da57ac03801a968b7131b8f2 100644 (file)
@@ -101,6 +101,10 @@ public:
   /// immediately before the specified instruction.
   void insertBefore(Instruction *InsertPos);
 
+  /// insertAfter - Insert an unlinked instructions into a basic block
+  /// immediately after the specified instruction.
+  void insertAfter(Instruction *InsertPos);
+
   /// moveBefore - Unlink this instruction from its current basic block and
   /// insert it into the basic block that MovePos lives in, right before
   /// MovePos.
index 6635e704e2ac9fbc440df8dd917d1eca54b25d4f..b09ab93aa11d7885292a16d71486df9bf5ca1bfc 100644 (file)
@@ -74,6 +74,12 @@ void Instruction::insertBefore(Instruction *InsertPos) {
   InsertPos->getParent()->getInstList().insert(InsertPos, this);
 }
 
+/// insertAfter - Insert an unlinked instructions into a basic block
+/// immediately after the specified instruction.
+void Instruction::insertAfter(Instruction *InsertPos) {
+  InsertPos->getParent()->getInstList().insertAfter(InsertPos, this);
+}
+
 /// moveBefore - Unlink this instruction from its current basic block and
 /// insert it into the basic block that MovePos lives in, right before
 /// MovePos.