10 #ifndef LLVM_SUPPORT_BINARYSTREAMARRAY_H 11 #define LLVM_SUPPORT_BINARYSTREAMARRAY_H 48 T &Item)
const =
delete;
102 : Stream(Stream), E(E) {}
104 Iterator
begin(
bool *HadError =
nullptr)
const {
105 return Iterator(*
this,
E, HadError);
108 bool valid()
const {
return Stream.valid(); }
110 Iterator
end()
const {
return Iterator(
E); }
112 bool empty()
const {
return Stream.getLength() == 0; }
119 return Iterator(*
this,
E, Offset,
nullptr);
133 template <
typename ValueType,
typename Extractor>
136 std::forward_iterator_tag, ValueType> {
147 : IterRef(Array.Stream.drop_front(Offset)), Extract(E),
148 Array(&Array), AbsOffset(Offset), HadError(HadError) {
149 if (IterRef.getLength() == 0)
152 auto EC = Extract(IterRef, ThisLen, ThisValue);
165 if (
Array && R.Array) {
168 return IterRef == R.IterRef;
172 if (!
Array && !R.Array)
190 for (
unsigned I = 0;
I <
N; ++
I) {
193 AbsOffset += ThisLen;
194 IterRef = IterRef.drop_front(ThisLen);
195 if (IterRef.getLength() == 0) {
201 auto EC = Extract(IterRef, ThisLen, ThisValue);
205 }
else if (ThisLen == 0) {
225 if (HadError !=
nullptr)
232 const ArrayType *
Array{
nullptr};
235 bool HasError{
false};
236 bool *HadError{
nullptr};
258 return Stream == Other.Stream;
262 return !(*
this ==
Other);
271 if (
auto EC = Stream.readBytes(Off,
sizeof(
T), Data)) {
272 assert(
false &&
"Unexpected failure reading from stream");
278 return *
reinterpret_cast<const T *
>(Data.data());
305 template <
typename T>
308 std::random_access_iterator_tag, const T> {
312 : Array(Array), Index(Index) {}
326 return (
Index == R.Index) && (
Array == R.Array);
343 return Index - R.Index;
346 bool operator<(const FixedStreamArrayIterator<T> &RHS)
const {
348 return Index < RHS.Index;
358 #endif // LLVM_SUPPORT_BINARYSTREAMARRAY_H const_iterator end(StringRef path)
Get end iterator over path.
bool operator==(const IterType &R) const
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
const ValueType & operator*() const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Compute iterated dominance frontiers using a linear time algorithm.
void setUnderlyingStream(BinaryStreamRef S)
VarStreamArray(const Extractor &E)
bool operator!=(const FixedStreamArray< T > &Other) const
BinaryStreamRef getUnderlyingStream() const
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
FixedStreamArrayIterator< T > Iterator
const T & operator[](uint32_t Index) const
FixedStreamArrayIterator< T > & operator=(const FixedStreamArrayIterator< T > &Other)
VarStreamArray(BinaryStreamRef Stream, const Extractor &E)
Class to represent array types.
VarStreamArray(BinaryStreamRef Stream)
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
VarStreamArrayIterator(const ArrayType &Array, const Extractor &E, uint32_t Offset, bool *HadError)
Extractor & getExtractor()
VarStreamArrayIterator< ValueType, Extractor > Iterator
uint32_t getRecordLength() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
size_t alignmentAdjustment(const void *Ptr, size_t Alignment)
Returns the necessary adjustment for aligning Ptr to Alignment bytes, rounding up.
VarStreamArrayIterator(const Extractor &E)
bool operator==(const FixedStreamArrayIterator< T > &R) const
const T & operator*() const
IterType & operator+=(unsigned N)
void consumeError(Error Err)
Consume a Error without doing anything.
FixedStreamArray(BinaryStreamRef Stream)
uint32_t getLength() const
VarStreamArrayIterator(const ArrayType &Array, const Extractor &E, bool *HadError)
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
FixedStreamArrayIterator(const FixedStreamArray< T > &Array, uint32_t Index)
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
VarStreamArray represents an array of variable length records backed by a stream. ...
FixedStreamArrayIterator< T > & operator-=(std::ptrdiff_t N)
FixedStreamArrayIterator< T > & operator+=(std::ptrdiff_t N)
BinaryStreamRef getUnderlyingStream() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FixedStreamArrayIterator< T > end() const
Iterator at(uint32_t Offset) const
given an offset into the array's underlying stream, return an iterator to the record at that offset...
Iterator begin(bool *HadError=nullptr) const
const Extractor & getExtractor() const
std::ptrdiff_t operator-(const FixedStreamArrayIterator< T > &R) const
Lightweight error class with error context and mandatory checking.
bool operator==(const FixedStreamArray< T > &Other) const
FixedStreamArrayIterator< T > begin() const
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...