003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/ADT
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
ADT
/
📁
..
📄
APFloat.h
(48.83 KB)
📄
APInt.h
(74.48 KB)
📄
APSInt.h
(11.75 KB)
📄
AllocatorList.h
(7.53 KB)
📄
Any.h
(5.05 KB)
📄
ArrayRef.h
(17.92 KB)
📄
BitVector.h
(29.74 KB)
📄
Bitfields.h
(11.65 KB)
📄
BitmaskEnum.h
(5.53 KB)
📄
BreadthFirstIterator.h
(4.82 KB)
📄
CachedHashString.h
(5.9 KB)
📄
CoalescingBitVector.h
(14.91 KB)
📄
DAGDeltaAlgorithm.h
(3.13 KB)
📄
DeltaAlgorithm.h
(3.54 KB)
📄
DenseMap.h
(43.14 KB)
📄
DenseMapInfo.h
(11.4 KB)
📄
DenseSet.h
(9.33 KB)
📄
DepthFirstIterator.h
(10.37 KB)
📄
DirectedGraph.h
(9.56 KB)
📄
EnumeratedArray.h
(1.6 KB)
📄
EpochTracker.h
(3.2 KB)
📄
EquivalenceClasses.h
(10.52 KB)
📄
FloatingPointMode.h
(5.62 KB)
📄
FoldingSet.h
(30.16 KB)
📄
FunctionExtras.h
(14.55 KB)
📄
GraphTraits.h
(5.71 KB)
📄
Hashing.h
(25.12 KB)
📄
ImmutableList.h
(7.57 KB)
📄
ImmutableMap.h
(10.84 KB)
📄
ImmutableSet.h
(37.52 KB)
📄
IndexedMap.h
(2.5 KB)
📄
IntEqClasses.h
(2.87 KB)
📄
IntervalMap.h
(72.88 KB)
📄
IntrusiveRefCntPtr.h
(8.1 KB)
📄
MapVector.h
(7.79 KB)
📄
None.h
(983 B)
📄
Optional.h
(10.82 KB)
📄
PackedVector.h
(4.17 KB)
📄
PointerEmbeddedInt.h
(4.05 KB)
📄
PointerIntPair.h
(8.72 KB)
📄
PointerSumType.h
(11.61 KB)
📄
PointerUnion.h
(10.17 KB)
📄
PostOrderIterator.h
(11.05 KB)
📄
PriorityQueue.h
(2.69 KB)
📄
PriorityWorklist.h
(8.11 KB)
📄
SCCIterator.h
(8.02 KB)
📄
STLExtras.h
(70.56 KB)
📄
ScopeExit.h
(1.83 KB)
📄
ScopedHashTable.h
(8.27 KB)
📄
Sequence.h
(2.59 KB)
📄
SetOperations.h
(2.58 KB)
📄
SetVector.h
(9.39 KB)
📄
SmallBitVector.h
(20.36 KB)
📄
SmallPtrSet.h
(16.93 KB)
📄
SmallSet.h
(8.37 KB)
📄
SmallString.h
(8.55 KB)
📄
SmallVector.h
(32.33 KB)
📄
SparseBitVector.h
(26.2 KB)
📄
SparseMultiSet.h
(17.83 KB)
📄
SparseSet.h
(11.41 KB)
📄
Statistic.h
(7.01 KB)
📄
StringExtras.h
(13.25 KB)
📄
StringMap.h
(15.7 KB)
📄
StringMapEntry.h
(4.83 KB)
📄
StringRef.h
(31.68 KB)
📄
StringSet.h
(1.51 KB)
📄
StringSwitch.h
(6.25 KB)
📄
TinyPtrVector.h
(10.19 KB)
📄
Triple.h
(27.4 KB)
📄
Twine.h
(17.48 KB)
📄
TypeSwitch.h
(5.82 KB)
📄
UniqueVector.h
(3.09 KB)
📄
Waymarking.h
(11.96 KB)
📄
bit.h
(2.26 KB)
📄
edit_distance.h
(3.57 KB)
📄
fallible_iterator.h
(8.31 KB)
📄
ilist.h
(13.68 KB)
📄
ilist_base.h
(2.72 KB)
📄
ilist_iterator.h
(7.21 KB)
📄
ilist_node.h
(9.84 KB)
📄
ilist_node_base.h
(1.7 KB)
📄
ilist_node_options.h
(5.07 KB)
📄
iterator.h
(13.46 KB)
📄
iterator_range.h
(2.22 KB)
📄
simple_ilist.h
(10.78 KB)
Editing: ilist_iterator.h
//===- llvm/ADT/ilist_iterator.h - Intrusive List Iterator ------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_ADT_ILIST_ITERATOR_H #define LLVM_ADT_ILIST_ITERATOR_H #include "llvm/ADT/ilist_node.h" #include <cassert> #include <cstddef> #include <iterator> #include <type_traits> namespace llvm { namespace ilist_detail { /// Find const-correct node types. template <class OptionsT, bool IsConst> struct IteratorTraits; template <class OptionsT> struct IteratorTraits<OptionsT, false> { using value_type = typename OptionsT::value_type; using pointer = typename OptionsT::pointer; using reference = typename OptionsT::reference; using node_pointer = ilist_node_impl<OptionsT> *; using node_reference = ilist_node_impl<OptionsT> &; }; template <class OptionsT> struct IteratorTraits<OptionsT, true> { using value_type = const typename OptionsT::value_type; using pointer = typename OptionsT::const_pointer; using reference = typename OptionsT::const_reference; using node_pointer = const ilist_node_impl<OptionsT> *; using node_reference = const ilist_node_impl<OptionsT> &; }; template <bool IsReverse> struct IteratorHelper; template <> struct IteratorHelper<false> : ilist_detail::NodeAccess { using Access = ilist_detail::NodeAccess; template <class T> static void increment(T *&I) { I = Access::getNext(*I); } template <class T> static void decrement(T *&I) { I = Access::getPrev(*I); } }; template <> struct IteratorHelper<true> : ilist_detail::NodeAccess { using Access = ilist_detail::NodeAccess; template <class T> static void increment(T *&I) { I = Access::getPrev(*I); } template <class T> static void decrement(T *&I) { I = Access::getNext(*I); } }; } // end namespace ilist_detail /// Iterator for intrusive lists based on ilist_node. template <class OptionsT, bool IsReverse, bool IsConst> class ilist_iterator : ilist_detail::SpecificNodeAccess<OptionsT> { friend ilist_iterator<OptionsT, IsReverse, !IsConst>; friend ilist_iterator<OptionsT, !IsReverse, IsConst>; friend ilist_iterator<OptionsT, !IsReverse, !IsConst>; using Traits = ilist_detail::IteratorTraits<OptionsT, IsConst>; using Access = ilist_detail::SpecificNodeAccess<OptionsT>; public: using value_type = typename Traits::value_type; using pointer = typename Traits::pointer; using reference = typename Traits::reference; using difference_type = ptrdiff_t; using iterator_category = std::bidirectional_iterator_tag; using const_pointer = typename OptionsT::const_pointer; using const_reference = typename OptionsT::const_reference; private: using node_pointer = typename Traits::node_pointer; using node_reference = typename Traits::node_reference; node_pointer NodePtr = nullptr; public: /// Create from an ilist_node. explicit ilist_iterator(node_reference N) : NodePtr(&N) {} explicit ilist_iterator(pointer NP) : NodePtr(Access::getNodePtr(NP)) {} explicit ilist_iterator(reference NR) : NodePtr(Access::getNodePtr(&NR)) {} ilist_iterator() = default; // This is templated so that we can allow constructing a const iterator from // a nonconst iterator... template <bool RHSIsConst> ilist_iterator(const ilist_iterator<OptionsT, IsReverse, RHSIsConst> &RHS, std::enable_if_t<IsConst || !RHSIsConst, void *> = nullptr) : NodePtr(RHS.NodePtr) {} // This is templated so that we can allow assigning to a const iterator from // a nonconst iterator... template <bool RHSIsConst> std::enable_if_t<IsConst || !RHSIsConst, ilist_iterator &> operator=(const ilist_iterator<OptionsT, IsReverse, RHSIsConst> &RHS) { NodePtr = RHS.NodePtr; return *this; } /// Explicit conversion between forward/reverse iterators. /// /// Translate between forward and reverse iterators without changing range /// boundaries. The resulting iterator will dereference (and have a handle) /// to the previous node, which is somewhat unexpected; but converting the /// two endpoints in a range will give the same range in reverse. /// /// This matches std::reverse_iterator conversions. explicit ilist_iterator( const ilist_iterator<OptionsT, !IsReverse, IsConst> &RHS) : ilist_iterator(++RHS.getReverse()) {} /// Get a reverse iterator to the same node. /// /// Gives a reverse iterator that will dereference (and have a handle) to the /// same node. Converting the endpoint iterators in a range will give a /// different range; for range operations, use the explicit conversions. ilist_iterator<OptionsT, !IsReverse, IsConst> getReverse() const { if (NodePtr) return ilist_iterator<OptionsT, !IsReverse, IsConst>(*NodePtr); return ilist_iterator<OptionsT, !IsReverse, IsConst>(); } /// Const-cast. ilist_iterator<OptionsT, IsReverse, false> getNonConst() const { if (NodePtr) return ilist_iterator<OptionsT, IsReverse, false>( const_cast<typename ilist_iterator<OptionsT, IsReverse, false>::node_reference>(*NodePtr)); return ilist_iterator<OptionsT, IsReverse, false>(); } // Accessors... reference operator*() const { assert(!NodePtr->isKnownSentinel()); return *Access::getValuePtr(NodePtr); } pointer operator->() const { return &operator*(); } // Comparison operators friend bool operator==(const ilist_iterator &LHS, const ilist_iterator &RHS) { return LHS.NodePtr == RHS.NodePtr; } friend bool operator!=(const ilist_iterator &LHS, const ilist_iterator &RHS) { return LHS.NodePtr != RHS.NodePtr; } // Increment and decrement operators... ilist_iterator &operator--() { NodePtr = IsReverse ? NodePtr->getNext() : NodePtr->getPrev(); return *this; } ilist_iterator &operator++() { NodePtr = IsReverse ? NodePtr->getPrev() : NodePtr->getNext(); return *this; } ilist_iterator operator--(int) { ilist_iterator tmp = *this; --*this; return tmp; } ilist_iterator operator++(int) { ilist_iterator tmp = *this; ++*this; return tmp; } /// Get the underlying ilist_node. node_pointer getNodePtr() const { return static_cast<node_pointer>(NodePtr); } /// Check for end. Only valid if ilist_sentinel_tracking<true>. bool isEnd() const { return NodePtr ? NodePtr->isSentinel() : false; } }; template <typename From> struct simplify_type; /// Allow ilist_iterators to convert into pointers to a node automatically when /// used by the dyn_cast, cast, isa mechanisms... /// /// FIXME: remove this, since there is no implicit conversion to NodeTy. template <class OptionsT, bool IsConst> struct simplify_type<ilist_iterator<OptionsT, false, IsConst>> { using iterator = ilist_iterator<OptionsT, false, IsConst>; using SimpleType = typename iterator::pointer; static SimpleType getSimplifiedValue(const iterator &Node) { return &*Node; } }; template <class OptionsT, bool IsConst> struct simplify_type<const ilist_iterator<OptionsT, false, IsConst>> : simplify_type<ilist_iterator<OptionsT, false, IsConst>> {}; } // end namespace llvm #endif // LLVM_ADT_ILIST_ITERATOR_H
Upload File
Create Folder