File indexing completed on 2026-05-10 08:43:06
0001
0002
0003
0004
0005
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 }
0060
0061
0062
0063
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 }
0071
0072 #endif