9 #ifndef LLVM_SUPPORT_BINARYSTREAMARRAY_H 10 #define LLVM_SUPPORT_BINARYSTREAMARRAY_H 47 T &Item)
const =
delete;
99 : Stream(Stream), Skew(Skew) {}
102 : Stream(Stream), E(E), Skew(Skew) {}
104 Iterator
begin(
bool *HadError =
nullptr)
const {
105 return Iterator(*
this,
E, Skew,
nullptr);
108 bool valid()
const {
return Stream.valid(); }
111 Iterator
end()
const {
return Iterator(
E); }
113 bool empty()
const {
return Stream.getLength() == 0; }
121 return {NewStream,
E, Begin};
129 return Iterator(*
this,
E, Offset,
nullptr);
149 template <
typename ValueType,
typename Extractor>
152 std::forward_iterator_tag, ValueType> {
159 : IterRef(Array.Stream.drop_front(Offset)), Extract(E),
160 Array(&Array), AbsOffset(Offset), HadError(HadError) {
161 if (IterRef.getLength() == 0)
164 auto EC = Extract(IterRef, ThisLen, ThisValue);
177 if (Array && R.Array) {
180 return IterRef == R.IterRef;
184 if (!Array && !R.Array)
192 assert(Array && !HasError);
197 assert(Array && !HasError);
202 for (
unsigned I = 0;
I <
N; ++
I) {
205 AbsOffset += ThisLen;
206 IterRef = IterRef.drop_front(ThisLen);
207 if (IterRef.getLength() == 0) {
213 auto EC = Extract(IterRef, ThisLen, ThisValue);
217 }
else if (ThisLen == 0) {
237 if (HadError !=
nullptr)
244 const ArrayType *Array{
nullptr};
247 bool HasError{
false};
248 bool *HadError{
nullptr};
270 return Stream == Other.Stream;
274 return !(*
this ==
Other);
284 if (
auto EC = Stream.readBytes(Off,
sizeof(
T), Data)) {
285 assert(
false &&
"Unexpected failure reading from stream");
291 return *
reinterpret_cast<const T *
>(Data.data());
318 template <
typename T>
321 std::random_access_iterator_tag, const T> {
325 : Array(Array), Index(Index) {}
341 return (
Index == R.Index) && (Array == R.Array);
358 return Index - R.Index;
361 bool operator<(const FixedStreamArrayIterator<T> &RHS)
const {
362 assert(Array == RHS.Array);
363 return Index < RHS.Index;
373 #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
RefType slice(uint32_t Offset, uint32_t Len) const
Return a new BinaryStreamRef with the first Offset elements removed, and retaining exactly Len elemen...
const ValueType & operator*() const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
VarStreamArray(const Extractor &E)
VarStreamArray(BinaryStreamRef Stream, const Extractor &E, uint32_t Skew=0)
bool operator!=(const FixedStreamArray< T > &Other) const
BinaryStreamRef getUnderlyingStream() const
void setUnderlyingStream(BinaryStreamRef NewStream, uint32_t NewSkew=0)
VarStreamArray(BinaryStreamRef Stream, uint32_t Skew=0)
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
VarStreamArray< ValueType, Extractor > substream(uint32_t Begin, uint32_t End) const
FixedStreamArrayIterator< T > Iterator
const T & operator[](uint32_t Index) const
FixedStreamArrayIterator< T > & operator=(const FixedStreamArrayIterator< T > &Other)
Class to represent array types.
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")
VarStreamArrayIterator(const Extractor &E)
bool operator==(const FixedStreamArrayIterator< T > &R) const
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.
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
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 or more pointer types, with the discriminator in the low bit of the poin...