File indexing completed on 2026-05-10 08:43:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H
0011
0012 #include "llvm/ADT/ArrayRef.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/DebugInfo/CodeView/TypeCollection.h"
0015 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
0016 #include "llvm/Support/Allocator.h"
0017 #include "llvm/Support/BinaryStreamArray.h"
0018 #include "llvm/Support/Error.h"
0019 #include "llvm/Support/StringSaver.h"
0020 #include <cstdint>
0021 #include <vector>
0022
0023 namespace llvm {
0024 namespace codeview {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 class LazyRandomTypeCollection : public TypeCollection {
0049 using PartialOffsetArray = FixedStreamArray<TypeIndexOffset>;
0050
0051 struct CacheEntry {
0052 CVType Type;
0053 uint32_t Offset;
0054 StringRef Name;
0055 };
0056
0057 public:
0058 explicit LazyRandomTypeCollection(uint32_t RecordCountHint);
0059 LazyRandomTypeCollection(StringRef Data, uint32_t RecordCountHint);
0060 LazyRandomTypeCollection(ArrayRef<uint8_t> Data, uint32_t RecordCountHint);
0061 LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint,
0062 PartialOffsetArray PartialOffsets);
0063 LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint);
0064
0065 void reset(ArrayRef<uint8_t> Data, uint32_t RecordCountHint);
0066 void reset(StringRef Data, uint32_t RecordCountHint);
0067 void reset(BinaryStreamReader &Reader, uint32_t RecordCountHint);
0068
0069 uint32_t getOffsetOfType(TypeIndex Index);
0070
0071 std::optional<CVType> tryGetType(TypeIndex Index);
0072
0073 CVType getType(TypeIndex Index) override;
0074 StringRef getTypeName(TypeIndex Index) override;
0075 bool contains(TypeIndex Index) override;
0076 uint32_t size() override;
0077 uint32_t capacity() override;
0078 std::optional<TypeIndex> getFirst() override;
0079 std::optional<TypeIndex> getNext(TypeIndex Prev) override;
0080 bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override;
0081
0082 private:
0083 Error ensureTypeExists(TypeIndex Index);
0084 void ensureCapacityFor(TypeIndex Index);
0085
0086 Error visitRangeForType(TypeIndex TI);
0087 Error fullScanForType(TypeIndex TI);
0088 void visitRange(TypeIndex Begin, uint32_t BeginOffset, TypeIndex End);
0089
0090
0091 uint32_t Count = 0;
0092
0093
0094 TypeIndex LargestTypeIndex = TypeIndex::None();
0095
0096 BumpPtrAllocator Allocator;
0097 StringSaver NameStorage;
0098
0099
0100 CVTypeArray Types;
0101
0102 std::vector<CacheEntry> Records;
0103
0104
0105
0106
0107
0108 PartialOffsetArray PartialOffsets;
0109 };
0110
0111 }
0112 }
0113
0114 #endif