[NFC] Cleanup: Function::getBasicBlockList() and Function::getSublistAccess() are...
authorVasileios Porpodas <vporpodas@google.com>
Wed, 14 Dec 2022 00:02:50 +0000 (16:02 -0800)
committerVasileios Porpodas <vporpodas@google.com>
Fri, 16 Dec 2022 05:41:24 +0000 (21:41 -0800)
The Function class now supports an adequate set of member functions to help
modify the BB list, including Function::splice(), Function::erase(),
Function::insert() etc. so we no longer need access to the underlying list.

Differential Revision: https://reviews.llvm.org/D140162

llvm/include/llvm/IR/Function.h

index 8d0f318..75650e2 100644 (file)
@@ -719,6 +719,15 @@ public:
   /// \Returns \p ToIt.
   Function::iterator erase(Function::iterator FromIt, Function::iterator ToIt);
 
+private:
+  // These need access to the underlying BB list.
+  friend void BasicBlock::removeFromParent();
+  friend iplist<BasicBlock>::iterator BasicBlock::eraseFromParent();
+  template <class BB_t, class BB_i_t, class BI_t, class II_t>
+  friend class InstIterator;
+  friend class llvm::SymbolTableListTraits<llvm::BasicBlock>;
+  friend class llvm::ilist_node_with_parent<llvm::BasicBlock, llvm::Function>;
+
   /// Get the underlying elements of the Function... the basic block list is
   /// empty for external functions.
   ///
@@ -732,6 +741,7 @@ public:
     return &Function::BasicBlocks;
   }
 
+public:
   const BasicBlock       &getEntryBlock() const   { return front(); }
         BasicBlock       &getEntryBlock()         { return front(); }