33 PartialOffsetArray()) {}
37 PartialOffsetArray PartialOffsets)
38 : NameStorage(Allocator), Types(Types), PartialOffsets(PartialOffsets) {
39 Records.resize(RecordCountHint);
59 PartialOffsets = PartialOffsetArray();
65 Records.resize(RecordCountHint);
70 reset(Reader, RecordCountHint);
76 reset(Reader, RecordCountHint);
80 error(ensureTypeExists(Index));
83 return Records[Index.toArrayIndex()].Offset;
89 auto EC = ensureTypeExists(Index);
93 return Records[Index.toArrayIndex()].Type;
100 if (
auto EC = ensureTypeExists(Index)) {
107 return Records[Index.toArrayIndex()].Type;
111 if (Index.isNoneType() || Index.isSimple())
118 if (
auto EC = ensureTypeExists(Index)) {
120 return "<unknown UDT>";
124 ensureCapacityFor(Index);
125 if (Records[
I].Name.data() ==
nullptr) {
127 Records[
I].Name = Result;
129 return Records[
I].Name;
133 if (Index.isSimple() || Index.isNoneType())
136 if (Records.size() <= Index.toArrayIndex())
138 if (!Records[Index.toArrayIndex()].Type.valid())
151 return visitRangeForType(TI);
154void LazyRandomTypeCollection::ensureCapacityFor(
TypeIndex Index) {
155 assert(!Index.isSimple());
156 uint32_t MinSize = Index.toArrayIndex() + 1;
161 uint32_t NewCapacity = MinSize * 3 / 2;
164 Records.resize(NewCapacity);
169 if (PartialOffsets.
empty())
170 return fullScanForType(TI);
178 auto Prev = std::prev(
Next);
180 TypeIndex TIB = Prev->Type;
191 if (
Next == PartialOffsets.end()) {
197 visitRange(TIB, Prev->Offset, TIE);
203 if (
auto EC = ensureTypeExists(TI)) {
214 if (
auto EC = ensureTypeExists(Prev + 1)) {
227 auto Begin = Types.begin();
239 CurrentTI = LargestTypeIndex + 1;
244 auto End = Types.end();
245 while (Begin != End) {
246 ensureCapacityFor(CurrentTI);
247 LargestTypeIndex = std::max(LargestTypeIndex, CurrentTI);
249 Records[Idx].Type = *Begin;
250 Records[Idx].Offset = Begin.offset();
255 if (CurrentTI <= TI) {
261void LazyRandomTypeCollection::visitRange(
TypeIndex Begin, uint32_t BeginOffset,
263 auto RI = Types.at(BeginOffset);
264 assert(RI != Types.end());
266 ensureCapacityFor(End);
267 while (Begin != End) {
268 LargestTypeIndex = std::max(LargestTypeIndex, Begin);
270 Records[Idx].Type = *RI;
271 Records[Idx].Offset = RI.offset();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Provides read only access to a subclass of BinaryStream.
uint64_t bytesRemaining() const
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
std::optional< TypeIndex > getNext(TypeIndex Prev) override
std::optional< CVType > tryGetType(TypeIndex Index)
CVType getType(TypeIndex Index) override
uint32_t getOffsetOfType(TypeIndex Index)
uint32_t capacity() override
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
StringRef getTypeName(TypeIndex Index) override
bool contains(TypeIndex Index) override
std::optional< TypeIndex > getFirst() override
void reset(ArrayRef< uint8_t > Data, uint32_t RecordCountHint)
LazyRandomTypeCollection(uint32_t RecordCountHint)
static TypeIndex fromArrayIndex(uint32_t Index)
uint32_t toArrayIndex() const
static LLVM_ABI StringRef simpleTypeName(TypeIndex TI)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CVRecord< TypeLeafKind > CVType
VarStreamArray< CVType > CVTypeArray
LLVM_ABI std::string computeTypeName(TypeCollection &Types, TypeIndex Index)
This is an optimization pass for GlobalISel generic memory operations.
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
FunctionAddr VTableAddr Count
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
FunctionAddr VTableAddr Next
void consumeError(Error Err)
Consume a Error without doing anything.