10 #ifndef LLVM_SUPPORT_BINARYSTREAMARRAY_H 11 #define LLVM_SUPPORT_BINARYSTREAMARRAY_H 48 T &Item)
const =
delete;
100 : Stream(Stream), Skew(Skew) {}
103 : Stream(Stream), E(E), Skew(Skew) {}
105 Iterator
begin(
bool *HadError =
nullptr)
const {
106 return Iterator(*
this,
E, Skew,
nullptr);
109 bool valid()
const {
return Stream.valid(); }
112 Iterator
end()
const {
return Iterator(
E); }
114 bool empty()
const {
return Stream.getLength() == 0; }
122 return {NewStream,
E, Begin};
130 return Iterator(*
this,
E, Offset,
nullptr);
150 template <
typename ValueType,
typename Extractor>
153 std::forward_iterator_tag, ValueType> {
160 : IterRef(Array.Stream.drop_front(Offset)), Extract(E),
161 Array(&Array), AbsOffset(Offset), HadError(HadError) {
162 if (IterRef.getLength() == 0)
165 auto EC = Extract(IterRef, ThisLen, ThisValue);
178 if (Array && R.Array) {
181 return IterRef == R.IterRef;
185 if (!Array && !R.Array)
193 assert(Array && !HasError);
198 assert(Array && !HasError);
203 for (
unsigned I = 0;
I <
N; ++
I) {
206 AbsOffset += ThisLen;
207 IterRef = IterRef.drop_front(ThisLen);
208 if (IterRef.getLength() == 0) {
214 auto EC = Extract(IterRef, ThisLen, ThisValue);
218 }
else if (ThisLen == 0) {
238 if (HadError !=
nullptr)
245 const ArrayType *Array{
nullptr};
248 bool HasError{
false};
249 bool *HadError{
nullptr};
271 return Stream == Other.Stream;
275 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) {}
339 return (
Index == R.Index) && (Array == R.Array);
356 return Index - R.Index;
359 bool operator<(const FixedStreamArrayIterator<T> &RHS)
const {
360 assert(Array == RHS.Array);
361 return Index < RHS.Index;
371 #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
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
void setUnderlyingStream(BinaryStreamRef S, uint32_t Skew=0)
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")
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
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...