LLVM  14.0.0git
ilist_node_base.h
Go to the documentation of this file.
1 //===- llvm/ADT/ilist_node_base.h - Intrusive List Node Base -----*- C++ -*-==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_ADT_ILIST_NODE_BASE_H
10 #define LLVM_ADT_ILIST_NODE_BASE_H
11 
13 
14 namespace llvm {
15 
16 /// Base class for ilist nodes.
17 ///
18 /// Optionally tracks whether this node is the sentinel.
19 template <bool EnableSentinelTracking> class ilist_node_base;
20 
21 template <> class ilist_node_base<false> {
22  ilist_node_base *Prev = nullptr;
23  ilist_node_base *Next = nullptr;
24 
25 public:
26  void setPrev(ilist_node_base *Prev) { this->Prev = Prev; }
27  void setNext(ilist_node_base *Next) { this->Next = Next; }
28  ilist_node_base *getPrev() const { return Prev; }
29  ilist_node_base *getNext() const { return Next; }
30 
31  bool isKnownSentinel() const { return false; }
33 };
34 
35 template <> class ilist_node_base<true> {
37  ilist_node_base *Next = nullptr;
38 
39 public:
40  void setPrev(ilist_node_base *Prev) { PrevAndSentinel.setPointer(Prev); }
41  void setNext(ilist_node_base *Next) { this->Next = Next; }
42  ilist_node_base *getPrev() const { return PrevAndSentinel.getPointer(); }
43  ilist_node_base *getNext() const { return Next; }
44 
45  bool isSentinel() const { return PrevAndSentinel.getInt(); }
46  bool isKnownSentinel() const { return isSentinel(); }
47  void initializeSentinel() { PrevAndSentinel.setInt(true); }
48 };
49 
50 } // end namespace llvm
51 
52 #endif // LLVM_ADT_ILIST_NODE_BASE_H
llvm::ilist_node_base< true >::getNext
ilist_node_base * getNext() const
Definition: ilist_node_base.h:43
llvm::ilist_node_base< true >::getPrev
ilist_node_base * getPrev() const
Definition: ilist_node_base.h:42
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::ilist_node_base< true >::isSentinel
bool isSentinel() const
Definition: ilist_node_base.h:45
llvm::ilist_node_base< true >::isKnownSentinel
bool isKnownSentinel() const
Definition: ilist_node_base.h:46
llvm::ilist_node_base
Base class for ilist nodes.
Definition: ilist_node_base.h:19
llvm::ilist_node_base< false >::getNext
ilist_node_base * getNext() const
Definition: ilist_node_base.h:29
llvm::ilist_node_base< false >::setNext
void setNext(ilist_node_base *Next)
Definition: ilist_node_base.h:27
isSentinel
static bool isSentinel(const DWARFDebugNames::AttributeEncoding &AE)
Definition: DWARFAcceleratorTable.cpp:425
PointerIntPair.h
llvm::ilist_node_base< false >::initializeSentinel
void initializeSentinel()
Definition: ilist_node_base.h:32
llvm::ilist_node_base< true >::initializeSentinel
void initializeSentinel()
Definition: ilist_node_base.h:47
false
Definition: StackSlotColoring.cpp:142
llvm::ilist_node_base< false >::isKnownSentinel
bool isKnownSentinel() const
Definition: ilist_node_base.h:31
llvm::ilist_node_base< true >::setNext
void setNext(ilist_node_base *Next)
Definition: ilist_node_base.h:41
llvm::ilist_node_base< false >::getPrev
ilist_node_base * getPrev() const
Definition: ilist_node_base.h:28
llvm::ilist_node_base< false >::setPrev
void setPrev(ilist_node_base *Prev)
Definition: ilist_node_base.h:26
llvm::PointerIntPair
PointerIntPair - This class implements a pair of a pointer and small integer.
Definition: PointerIntPair.h:45
llvm::ilist_node_base< true >::setPrev
void setPrev(ilist_node_base *Prev)
Definition: ilist_node_base.h:40
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1815