[PATCH] Return iterator from BasicBlock::eraseFromParent

Phabricator reviews at reviews.llvm.org
Thu Apr 2 18:23:28 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8801

Files:
  llvm/trunk/include/llvm/IR/BasicBlock.h
  llvm/trunk/include/llvm/IR/Function.h
  llvm/trunk/lib/IR/BasicBlock.cpp

Index: llvm/trunk/include/llvm/IR/Function.h
===================================================================
--- llvm/trunk/include/llvm/IR/Function.h
+++ llvm/trunk/include/llvm/IR/Function.h
@@ -31,26 +31,6 @@
 class FunctionType;
 class LLVMContext;
 
-// Traits for intrusive list of basic blocks...
-template<> struct ilist_traits<BasicBlock>
-  : public SymbolTableListTraits<BasicBlock, Function> {
-
-  // createSentinel is used to get hold of the node that marks the end of the
-  // list... (same trick used here as in ilist_traits<Instruction>)
-  BasicBlock *createSentinel() const {
-    return static_cast<BasicBlock*>(&Sentinel);
-  }
-  static void destroySentinel(BasicBlock*) {}
-
-  BasicBlock *provideInitialHead() const { return createSentinel(); }
-  BasicBlock *ensureHead(BasicBlock*) const { return createSentinel(); }
-  static void noteHead(BasicBlock*, BasicBlock*) {}
-
-  static ValueSymbolTable *getSymTab(Function *ItemParent);
-private:
-  mutable ilist_half_node<BasicBlock> Sentinel;
-};
-
 template<> struct ilist_traits<Argument>
   : public SymbolTableListTraits<Argument, Function> {
 
Index: llvm/trunk/include/llvm/IR/BasicBlock.h
===================================================================
--- llvm/trunk/include/llvm/IR/BasicBlock.h
+++ llvm/trunk/include/llvm/IR/BasicBlock.h
@@ -28,6 +28,23 @@
 class TerminatorInst;
 class LLVMContext;
 class BlockAddress;
+class Function;
+
+// Traits for intrusive list of basic blocks...
+template<> struct ilist_traits<BasicBlock>
+  : public SymbolTableListTraits<BasicBlock, Function> {
+
+  BasicBlock *createSentinel() const;
+  static void destroySentinel(BasicBlock*) {}
+
+  BasicBlock *provideInitialHead() const { return createSentinel(); }
+  BasicBlock *ensureHead(BasicBlock*) const { return createSentinel(); }
+  static void noteHead(BasicBlock*, BasicBlock*) {}
+
+  static ValueSymbolTable *getSymTab(Function *ItemParent);
+private:
+  mutable ilist_half_node<BasicBlock> Sentinel;
+};
 
 
 /// \brief LLVM Basic Block Representation
@@ -151,7 +168,9 @@
   void removeFromParent();
 
   /// \brief Unlink 'this' from the containing function and delete it.
-  void eraseFromParent();
+  ///
+  // \returns an iterator pointing to the element after the erased one.
+  iplist<BasicBlock>::iterator eraseFromParent();
 
   /// \brief Unlink this basic block from its current function and insert it
   /// into the function that \p MovePos lives in, right before \p MovePos.
@@ -307,6 +326,12 @@
   }
 };
 
+// createSentinel is used to get hold of the node that marks the end of the
+// list... (same trick used here as in ilist_traits<Instruction>)
+inline BasicBlock *ilist_traits<BasicBlock>::createSentinel() const {
+    return static_cast<BasicBlock*>(&Sentinel);
+}
+
 // Create wrappers for C Binding types (see CBindingWrapping.h).
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef)
 
Index: llvm/trunk/lib/IR/BasicBlock.cpp
===================================================================
--- llvm/trunk/lib/IR/BasicBlock.cpp
+++ llvm/trunk/lib/IR/BasicBlock.cpp
@@ -94,8 +94,8 @@
   getParent()->getBasicBlockList().remove(this);
 }
 
-void BasicBlock::eraseFromParent() {
-  getParent()->getBasicBlockList().erase(this);
+iplist<BasicBlock>::iterator BasicBlock::eraseFromParent() {
+  return getParent()->getBasicBlockList().erase(this);
 }
 
 /// Unlink this basic block from its current function and

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8801.23191.patch
Type: text/x-patch
Size: 3443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150403/c51ef9a5/attachment.bin>


More information about the llvm-commits mailing list