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)) {
106 return Records[Index.toArrayIndex()].Type;
110 if (Index.isNoneType() || Index.isSimple())
117 if (
auto EC = ensureTypeExists(Index)) {
119 return "<unknown UDT>";
123 ensureCapacityFor(Index);
124 if (Records[
I].Name.data() ==
nullptr) {
126 Records[
I].Name = Result;
128 return Records[
I].Name;
132 if (Index.isSimple() || Index.isNoneType())
135 if (Records.size() <= Index.toArrayIndex())
137 if (!Records[Index.toArrayIndex()].Type.valid())
150 return visitRangeForType(TI);
153void LazyRandomTypeCollection::ensureCapacityFor(
TypeIndex Index) {
154 assert(!Index.isSimple());
155 uint32_t MinSize = Index.toArrayIndex() + 1;
160 uint32_t NewCapacity = MinSize * 3 / 2;
163 Records.resize(NewCapacity);
168 if (PartialOffsets.
empty())
169 return fullScanForType(TI);
177 auto Prev = std::prev(
Next);
179 TypeIndex TIB = Prev->Type;
190 if (
Next == PartialOffsets.end()) {
196 visitRange(TIB, Prev->Offset, TIE);
202 if (
auto EC = ensureTypeExists(TI)) {
213 if (
auto EC = ensureTypeExists(Prev + 1)) {
226 auto Begin = Types.begin();
238 CurrentTI = LargestTypeIndex + 1;
243 auto End = Types.end();
244 while (Begin != End) {
245 ensureCapacityFor(CurrentTI);
246 LargestTypeIndex = std::max(LargestTypeIndex, CurrentTI);
248 Records[Idx].Type = *Begin;
249 Records[Idx].Offset = Begin.offset();
254 if (CurrentTI <= TI) {
260void LazyRandomTypeCollection::visitRange(
TypeIndex Begin, uint32_t BeginOffset,
262 auto RI = Types.at(BeginOffset);
263 assert(RI != Types.end());
265 ensureCapacityFor(End);
266 while (Begin != End) {
267 LargestTypeIndex = std::max(LargestTypeIndex, Begin);
269 Records[Idx].Type = *RI;
270 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.