diff options
author | Zachary Turner <zturner@google.com> | 2017-11-29 19:35:21 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-11-29 19:35:21 +0000 |
commit | 3e3936da935dad0686184e03dee15ef37f037465 (patch) | |
tree | b17b0f5a456db9ecd980db4f3095a7003f0bb362 /llvm/lib | |
parent | 21e6efcb515054288fbd2aedc87fd484a1f70d3d (diff) | |
download | bcm5719-llvm-3e3936da935dad0686184e03dee15ef37f037465.tar.gz bcm5719-llvm-3e3936da935dad0686184e03dee15ef37f037465.zip |
Make TypeTableBuilder inherit from TypeCollection.
A couple of places in LLD were passing references to
TypeTableCollections around, which makes it hard to change the
implementation at runtime. However, these cases only needed to
iterate over the types in the collection, and TypeCollection
already provides a handy abstract interface for this purpose.
By implementing this interface, we can get rid of the need to
pass TypeTableBuilder references around, which should allow us
to swap the implementation at runtime in subsequent patches.
llvm-svn: 319345
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/TypeTableBuilder.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/TypeTableBuilder.cpp b/llvm/lib/DebugInfo/CodeView/TypeTableBuilder.cpp index 289bf6ca93c..2559b47e804 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeTableBuilder.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeTableBuilder.cpp @@ -142,6 +142,43 @@ TypeTableBuilder::TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash) TypeTableBuilder::~TypeTableBuilder() = default; +Optional<TypeIndex> TypeTableBuilder::getFirst() { + if (empty()) + return None; + + return TypeIndex(TypeIndex::FirstNonSimpleIndex); +} + +Optional<TypeIndex> TypeTableBuilder::getNext(TypeIndex Prev) { + if (++Prev == nextTypeIndex()) + return None; + return Prev; +} + +CVType TypeTableBuilder::getType(TypeIndex Index) { + CVType Type; + Type.RecordData = SeenRecords[Index.toArrayIndex()]; + const RecordPrefix *P = + reinterpret_cast<const RecordPrefix *>(Type.RecordData.data()); + Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind)); + return Type; +} + +StringRef TypeTableBuilder::getTypeName(TypeIndex Index) { + llvm_unreachable("Method not implemented"); +} + +bool TypeTableBuilder::contains(TypeIndex Index) { + if (Index.isSimple() || Index.isNoneType()) + return false; + + return Index.toArrayIndex() < SeenRecords.size(); +} + +uint32_t TypeTableBuilder::size() { return SeenRecords.size(); } + +uint32_t TypeTableBuilder::capacity() { return SeenRecords.size(); } + ArrayRef<ArrayRef<uint8_t>> TypeTableBuilder::records() const { return SeenRecords; } |