IR: Create SymbolTableList wrapper around iplist, NFC
[oota-llvm.git] / include / llvm / ADT / ilist_node.h
index 3de4f156d20e60629457aee7929152522fdfef6e..85d7a908096951639b1f51e8725036254f906d3d 100644 (file)
@@ -19,18 +19,21 @@ namespace llvm {
 
 template<typename NodeTy>
 struct ilist_traits;
+template <typename NodeTy> struct ilist_embedded_sentinel_traits;
+template <typename NodeTy> struct ilist_half_embedded_sentinel_traits;
 
 /// ilist_half_node - Base class that provides prev services for sentinels.
 ///
 template<typename NodeTy>
 class ilist_half_node {
   friend struct ilist_traits<NodeTy>;
+  friend struct ilist_half_embedded_sentinel_traits<NodeTy>;
   NodeTy *Prev;
 protected:
   NodeTy *getPrev() { return Prev; }
   const NodeTy *getPrev() const { return Prev; }
   void setPrev(NodeTy *P) { Prev = P; }
-  ilist_half_node() : Prev(0) {}
+  ilist_half_node() : Prev(nullptr) {}
 };
 
 template<typename NodeTy>
@@ -43,12 +46,14 @@ template<typename NodeTy>
 class ilist_node : private ilist_half_node<NodeTy> {
   friend struct ilist_nextprev_traits<NodeTy>;
   friend struct ilist_traits<NodeTy>;
+  friend struct ilist_half_embedded_sentinel_traits<NodeTy>;
+  friend struct ilist_embedded_sentinel_traits<NodeTy>;
   NodeTy *Next;
   NodeTy *getNext() { return Next; }
   const NodeTy *getNext() const { return Next; }
   void setNext(NodeTy *N) { Next = N; }
 protected:
-  ilist_node() : Next(0) {}
+  ilist_node() : Next(nullptr) {}
 
 public:
   /// @name Adjacent Node Accessors
@@ -60,18 +65,18 @@ public:
 
     // Check for sentinel.
     if (!Prev->getNext())
-      return 0;
+      return nullptr;
 
     return Prev;
   }
 
   /// \brief Get the previous node, or 0 for the list head.
   const NodeTy *getPrevNode() const {
-    NodeTy *Prev = this->getPrev();
+    const NodeTy *Prev = this->getPrev();
 
     // Check for sentinel.
     if (!Prev->getNext())
-      return 0;
+      return nullptr;
 
     return Prev;
   }
@@ -82,18 +87,18 @@ public:
 
     // Check for sentinel.
     if (!Next->getNext())
-      return 0;
+      return nullptr;
 
     return Next;
   }
 
   /// \brief Get the next node, or 0 for the list tail.
   const NodeTy *getNextNode() const {
-    NodeTy *Next = getNext();
+    const NodeTy *Next = getNext();
 
     // Check for sentinel.
     if (!Next->getNext())
-      return 0;
+      return nullptr;
 
     return Next;
   }