Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:06

0001 //===- llvm/ADT/ilist_node_base.h - Intrusive List Node Base -----*- C++ -*-==//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_ADT_ILIST_NODE_BASE_H
0010 #define LLVM_ADT_ILIST_NODE_BASE_H
0011 
0012 #include "llvm/ADT/PointerIntPair.h"
0013 
0014 namespace llvm {
0015 
0016 namespace ilist_detail {
0017 
0018 template <class NodeBase, bool EnableSentinelTracking> class node_base_prevnext;
0019 
0020 template <class NodeBase> class node_base_prevnext<NodeBase, false> {
0021   NodeBase *Prev = nullptr;
0022   NodeBase *Next = nullptr;
0023 
0024 public:
0025   void setPrev(NodeBase *Prev) { this->Prev = Prev; }
0026   void setNext(NodeBase *Next) { this->Next = Next; }
0027   NodeBase *getPrev() const { return Prev; }
0028   NodeBase *getNext() const { return Next; }
0029 
0030   bool isKnownSentinel() const { return false; }
0031   void initializeSentinel() {}
0032 };
0033 
0034 template <class NodeBase> class node_base_prevnext<NodeBase, true> {
0035   PointerIntPair<NodeBase *, 1> PrevAndSentinel;
0036   NodeBase *Next = nullptr;
0037 
0038 public:
0039   void setPrev(NodeBase *Prev) { PrevAndSentinel.setPointer(Prev); }
0040   void setNext(NodeBase *Next) { this->Next = Next; }
0041   NodeBase *getPrev() const { return PrevAndSentinel.getPointer(); }
0042   NodeBase *getNext() const { return Next; }
0043 
0044   bool isSentinel() const { return PrevAndSentinel.getInt(); }
0045   bool isKnownSentinel() const { return isSentinel(); }
0046   void initializeSentinel() { PrevAndSentinel.setInt(true); }
0047 };
0048 
0049 template <class ParentTy> class node_base_parent {
0050   ParentTy *Parent = nullptr;
0051 
0052 public:
0053   void setNodeBaseParent(ParentTy *Parent) { this->Parent = Parent; }
0054   inline const ParentTy *getNodeBaseParent() const { return Parent; }
0055   inline ParentTy *getNodeBaseParent() { return Parent; }
0056 };
0057 template <> class node_base_parent<void> {};
0058 
0059 } // end namespace ilist_detail
0060 
0061 /// Base class for ilist nodes.
0062 ///
0063 /// Optionally tracks whether this node is the sentinel.
0064 template <bool EnableSentinelTracking, class ParentTy>
0065 class ilist_node_base : public ilist_detail::node_base_prevnext<
0066                             ilist_node_base<EnableSentinelTracking, ParentTy>,
0067                             EnableSentinelTracking>,
0068                         public ilist_detail::node_base_parent<ParentTy> {};
0069 
0070 } // end namespace llvm
0071 
0072 #endif // LLVM_ADT_ILIST_NODE_BASE_H