9#ifndef LLVM_ADT_FALLIBLE_ITERATOR_H
10#define LLVM_ADT_FALLIBLE_ITERATOR_H
71 using enable_if_struct_deref_supported = std::enable_if_t<
72 !std::is_void<decltype(std::declval<T>().operator->())>
::value,
73 decltype(std::declval<T>().operator->())>;
99 decltype(
auto)
operator*() {
return *I; }
102 decltype(
auto)
operator*()
const {
return *I; }
106 template <
typename T = Underlying>
108 return I.operator->();
113 template <
typename T = Underlying>
114 enable_if_struct_deref_supported<const T>
operator->()
const {
115 return I.operator->();
126 assert(getErrPtr() &&
"Cannot increment end iterator");
127 if (
auto Err = I.inc())
128 handleError(std::move(Err));
142 assert(getErrPtr() &&
"Cannot decrement end iterator");
143 if (
auto Err = I.dec())
144 handleError(std::move(Err));
166 if (
LHS.isEnd() &&
RHS.isEnd())
170 "Invalid iterators can only be compared against end");
172 bool Equal =
LHS.I ==
RHS.I;
178 (void)!!*
RHS.getErrPtr();
180 (
void)!!*
LHS.getErrPtr();
198 Error *getErrPtr()
const {
return ErrState.getPointer(); }
200 bool isEnd()
const {
return getErrPtr() ==
nullptr; }
202 bool isValid()
const {
return !ErrState.getInt(); }
204 void handleError(Error Err) {
205 *getErrPtr() = std::move(Err);
206 ErrState.setPointer(
nullptr);
207 ErrState.setInt(
true);
210 void resetCheckedFlag() {
215 mutable PointerIntPair<Error *, 1> ErrState;
220template <
typename Underlying>
227template <
typename Underlying>
232template <
typename Underlying>
233iterator_range<fallible_iterator<Underlying>>
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Given that RA is a live value
This file defines the PointerIntPair class.
const MachineOperand & RHS
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
A wrapper class for fallible iterators.
static fallible_iterator end(Underlying I)
Construct a fallible iterator that can be used as an end-of-range value.
friend bool operator!=(const fallible_iterator &LHS, const fallible_iterator &RHS)
Compare fallible iterators for inequality.
static fallible_iterator itr(Underlying I, Error &Err)
Construct a fallible iterator that cannot be used as an end-of-range value.
fallible_iterator & operator--()
Decrement the fallible iterator.
friend bool operator==(const fallible_iterator &LHS, const fallible_iterator &RHS)
Compare fallible iterators for equality.
fallible_iterator & operator++()
Increment the fallible iterator.
enable_if_struct_deref_supported< const T > operator->() const
Forward const structure dereference to the underlying iterator (if the underlying iterator supports i...
enable_if_struct_deref_supported< T > operator->()
Forward structure dereference to the underlying iterator (if the underlying iterator supports it).
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
constexpr std::underlying_type_t< E > Underlying(E Val)
Check that Val is in range for E, and return Val cast to E's underlying type.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
fallible_iterator< Underlying > make_fallible_itr(Underlying I, Error &Err)
Convenience wrapper to make a fallible_iterator value from an instance of an underlying iterator and ...
fallible_iterator< Underlying > make_fallible_end(Underlying E)
Convenience wrapper to make a fallible_iterator end value from an instance of an underlying iterator.
iterator_range< fallible_iterator< Underlying > > make_fallible_range(Underlying I, Underlying E, Error &Err)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.