41 : NameStorage(Allocator), Types(Types), PartialOffsets(PartialOffsets) {
42 Records.resize(RecordCountHint);
53 makeArrayRef(Data.bytes_begin(), Data.bytes_end()), RecordCountHint) {
69 Records.resize(RecordCountHint);
74 reset(Reader, RecordCountHint);
80 reset(Reader, RecordCountHint);
84 error(ensureTypeExists(Index));
93 auto EC = ensureTypeExists(Index);
104 if (
auto EC = ensureTypeExists(Index)) {
121 if (
auto EC = ensureTypeExists(Index)) {
123 return "<unknown UDT>";
127 ensureCapacityFor(Index);
128 if (Records[I].
Name.data() ==
nullptr) {
130 Records[
I].Name = Result;
132 return Records[
I].Name;
154 return visitRangeForType(TI);
157 void LazyRandomTypeCollection::ensureCapacityFor(
TypeIndex Index) {
164 uint32_t NewCapacity = MinSize * 3 / 2;
167 Records.resize(NewCapacity);
172 if (PartialOffsets.
empty())
173 return fullScanForType(TI);
177 return Value < IO.Type;
181 auto Prev = std::prev(Next);
190 return make_error<CodeViewError>(
"Invalid type index");
194 if (Next == PartialOffsets.
end()) {
200 visitRange(TIB, Prev->Offset, TIE);
206 if (
auto EC = ensureTypeExists(TI)) {
217 if (
auto EC = ensureTypeExists(Prev + 1)) {
230 auto Begin = Types.
begin();
242 CurrentTI = LargestTypeIndex + 1;
243 Begin = Types.
at(Offset);
247 auto End = Types.
end();
248 while (Begin != End) {
249 ensureCapacityFor(CurrentTI);
250 LargestTypeIndex =
std::max(LargestTypeIndex, CurrentTI);
251 auto Idx = CurrentTI.toArrayIndex();
252 Records[Idx].Type = *Begin;
253 Records[Idx].Offset = Begin.offset();
258 if (CurrentTI <= TI) {
259 return make_error<CodeViewError>(
"Type Index does not exist!");
266 auto RI = Types.
at(BeginOffset);
269 ensureCapacityFor(End);
270 while (Begin != End) {
271 LargestTypeIndex =
std::max(LargestTypeIndex, Begin);
273 Records[Idx].Type = *RI;
274 Records[Idx].Offset = RI.offset();
This class represents lattice values for constants.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
bool contains(TypeIndex Index) override
std::string computeTypeName(TypeCollection &Types, TypeIndex Index)
LazyRandomTypeCollection(uint32_t RecordCountHint)
Optional< TypeIndex > getNext(TypeIndex Prev) override
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
void reset(ArrayRef< uint8_t > Data, uint32_t RecordCountHint)
static void error(Error &&EC)
CVType getType(TypeIndex Index) override
uint32_t toArrayIndex() const
static TypeIndex fromArrayIndex(uint32_t Index)
uint32_t capacity() override
static StringRef simpleTypeName(TypeIndex TI)
Optional< CVType > tryGetType(TypeIndex Index)
void consumeError(Error Err)
Consume a Error without doing anything.
StringRef getTypeName(TypeIndex Index) override
static ErrorSuccess success()
Create a success value.
Align max(MaybeAlign Lhs, Align Rhs)
StringRef save(const char *S)
uint32_t getOffsetOfType(TypeIndex Index)
uint32_t bytesRemaining() 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
Lightweight error class with error context and mandatory checking.
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
FixedStreamArrayIterator< T > begin() const
Optional< TypeIndex > getFirst() override
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 ...
Provides amortized O(1) random access to a CodeView type stream.
auto upper_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...