llvm::iterator_facade_base

CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of the interface.

Synopsis

Declared in <llvm/ADT/iterator.h>

template<
    typename DerivedT,
    typename IteratorCategoryT,
    typename T,
    typename DifferenceTypeT = std::ptrdiff_t,
    typename PointerT = T*,
    typename ReferenceT = T&>
class iterator_facade_base;

Description

Use this when it is reasonable to implement most of the iterator functionality in terms of a core subset. If you need special behavior or there are performance implications for this, you may want to override the relevant members instead.

Note, one abstraction that this does not provide is implementing subtraction in terms of addition by negating the difference. Negation isn't always information preserving, and I can see very reasonable iterator designs where this doesn't work well. It doesn't really force much added boilerplate anyways.

Another abstraction that this doesn't provide is implementing increment in terms of addition of one. These aren't equivalent for all iterator categories, and respecting that adds a lot of complexity for little gain.

Iterators are expected to have const rules analogous to pointers, with a single, const-qualified operator*() that returns ReferenceT. This matches the second and third pointers in the following example:


int Value;
{ int *I = &Value; }             // ReferenceT 'int&'
{ int *const I = &Value; }       // ReferenceT 'int&'; const
{ const int *I = &Value; }       // ReferenceT 'const int&'
{ const int *const I = &Value; } // ReferenceT 'const int&'; const

If an iterator facade returns a handle to its own state, then T (and PointerT and ReferenceT) should usually be const-qualified. Otherwise, if clients are expected to modify the handle itself, the field can be declared mutable or use const_cast.

Classes wishing to use iterator_facade_base should implement the following methods:

Forward Iterators: (All of the following methods)

  • DerivedT &operator=(const DerivedT &R);

  • bool operator==(const DerivedT &R) const;

  • T &operator*() const;

  • DerivedT &operator++();

Bidirectional Iterators: (All methods of forward iterators, plus the following)

  • DerivedT &operator--();

Random-access Iterators: (All methods of bidirectional iterators excluding the following)

  • DerivedT &operator++();

  • DerivedT &operator--(); (and plus the following)

  • bool operator<(const DerivedT &RHS) const;

  • DifferenceTypeT operator-(const DerivedT &R) const;

  • DerivedT &operator+=(DifferenceTypeT N);

  • DerivedT &operator-=(DifferenceTypeT N);

Type Aliases

NameDescription
difference_type Signed type used to express the distance between iterators.
iterator_category Iterator category tag for this facade.
pointer Pointer type returned by the iterator.
reference Reference type returned by the iterator.
value_type Value type produced by the iterator.

Enums

NameDescription
Unnamed enum Capability flags for the iterator category.

Member Functions

NameDescription
operator+ Advance the iterator by n and return the result.
operator++ Increment operators
operator- Retreat the iterator by n and return the result.
operator-- Decrement operators
operator-> Return a proxy pointer to the current element.
operator[] Return a proxy to the element at offset n.
operator<= Return true if this iterator is less than or equal to RHS.
operator> Return true if this iterator is greater than RHS.
operator>= Return true if this iterator is greater than or equal to RHS.

Protected Types

NameDescription
PointerProxy Proxy that yields a pointer from a copied reference.
ReferenceProxy Proxy that yields a reference from a copied iterator.

Friends

NameDescription
llvm::operator+Return an iterator n positions after i.

Derived Classes

NameDescription
BinaryAnnotationIterator
CaseItImpl
CaseIteratorImpl
DbiModuleSourceFilesIterator
FixedStreamArrayIterator
FunctionRecordIterator Iterator over Functions, optionally filtered to a single file. When filtering to a single file, the iterator requires a list of potential indices where to find the desired records to avoid quadratic behavior when repeatedly iterating over functions from different files.
HashTableIterator
Iterator
Iterator Forward iterator over the non-empty strings stored in the table.
Iterator An iterator for all entries in the table.
LineCoverageIterator An iterator over the LineCoverageStats objects for lines described by a CoverageData instance.
MIBundleOperandIteratorBase MIBundleOperandIteratorBase - Iterator that visits all operands in a bundle of MachineInstrs. This class is not intended to be used directly, use one of the sub-classes instead.
MemoryInfoIterator
RepeatedIterator A random-access iterator that always dereferences to the same value.
SameNameIterator An iterator for Entries all having the same string as key.
SmallSetIterator SmallSetIterator - This class implements a const_iterator for SmallSet by delegating to the underlying SmallVector or Set iterators.
SplittingIterator A forward iterator over partitions of string over a separator.
SymbolGroupIterator
VarStreamArrayIterator VarStreamArray represents an array of variable length records backed by a stream. This could be a contiguous sequence of bytes in memory, it could be a file on disk, or it could be a PDB stream where bytes are stored as discontiguous blocks in a file. Usually it is desirable to treat arrays as contiguous blocks of memory, but doing so with large PDB files, for example, could mean allocating huge amounts of memory just to allow re-ordering of stream data to be contiguous before iterating over it. By abstracting this out, we need not duplicate this memory, and we can iterate over arrays in arbitrarily formatted streams. Elements are parsed lazily on iteration, so there is no upfront cost associated with building or copying a VarStreamArray, no matter how large it may be.
attribute_iterator
concat_iterator Iterator wrapper that concatenates sequences together.
const_child_iterator Iteration over child cycles, yielding handles.
const_iterator
const_iterator Path iterator.
const_iterator
const_iterator
const_iterator
const_iterator
const_iterator Yields the index of each set bit, skipping unset bits via countr_zero.
def_chain_iterator Walks the defining accesses of MemoryDefs. Stops after we hit something that has no defining use (e.g. a MemoryPhi or liveOnEntry). Note that, when comparing against a null def_chain_iterator, this will compare equal only after walking said Phi/liveOnEntry.
indexed_accessor_iterator A utility class used to implement an iterator that contains some base object and an index. The iterator moves the index but keeps the base constant.
iterator Iterators for registry entries.
iterator Iterators for registry entries.
iterator
iterator
iterator
iterator An iterator to go through the expression operations.
iterator Iterators for registry entries.
iterator
iterator
iterator_adaptor_base CRTP base class for adapting an iterator to a different type.
location_op_iterator
location_op_iterator Iterator for ValueAsMetadata that internally uses direct pointer iteration over either a ValueAsMetadata* or a ValueAsMetadata**, dereferencing to the ValueAsMetadata .
memoryaccess_def_iterator_base Iterator base class used to implement const and non-const iterators over the defining accesses of a MemoryAccess.
nested_collection_iterator
object_refs_iterator Iterator for ObjectID.
phi_iterator_impl Iterator to walk just the phi nodes in the basic block.
postorder_ref_scc_iterator A post-order depth-first RefSCC iterator over the call graph.
reverse_iterator Reverse path iterator.
scc_iterator Enumerate the SCCs of a directed graph in reverse topological order of the SCC DAG.
upward_defs_iterator Provide an iterator that walks defs, giving both the memory access, and the current pointer location, updating the pointer location as it changes due to phi node translation.