From 2d02ceefdc005bb05ae36fd3604a3810723f6cb9 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 3 May 2016 22:18:17 +0000 Subject: Move CodeViewTypeStream to DebugInfo/CodeView Ability to parse codeview type streams is also needed by DebugInfoPDB for parsing PDBs, so moving this into a library gives us this option. Since DebugInfoPDB had already hand rolled some code to do this, that code is now convereted over to using this common abstraction. Differential Revision: http://reviews.llvm.org/D19887 Reviewed By: dblaikie, amccarth llvm-svn: 268454 --- llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp') diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp index 7ee4c60..703ae5d 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp @@ -88,25 +88,6 @@ std::error_code TpiStream::reload() { // The actual type records themselves come from this stream RecordsBuffer.initialize(Reader, Header->TypeRecordBytes); - TypeRecords.resize(TypeIndexEnd() - ::MinTypeIndex); - StreamReader RecordsReader(RecordsBuffer); - for (uint32_t I = TypeIndexBegin(); I < TypeIndexEnd(); ++I) { - HashedTypeRecord &Record = TypeRecords[I - ::MinTypeIndex]; - codeview::TypeRecordPrefix Prefix; - if (auto EC = RecordsReader.readObject(&Prefix)) - return EC; - - Record.Kind = - static_cast(static_cast(Prefix.Leaf)); - - // Since we read this entire buffer into a ByteStream, we are guaranteed - // that the entire buffer is contiguous (i.e. there's no longer a chance - // that it splits across a page boundary. So we can request a reference - // directly into the stream buffer to avoid unnecessary memory copies. - uint32_t RecordSize = Prefix.Len - sizeof(Prefix.Leaf); - if (auto EC = RecordsReader.getArrayRef(Record.Record, RecordSize)) - return EC; - } // Hash indices, hash values, etc come from the hash stream. MappedBlockStream HS(Header->HashStreamIndex, Pdb); @@ -136,8 +117,6 @@ uint32_t TpiStream::NumTypeRecords() const { return TypeIndexEnd() - TypeIndexBegin(); } -ArrayRef TpiStream::records() const { - const HashedTypeRecord *Begin = - &TypeRecords[TypeIndexBegin() - ::MinTypeIndex]; - return ArrayRef(Begin, NumTypeRecords()); +iterator_range TpiStream::types() const { + return codeview::makeTypeRange(RecordsBuffer.str()); } -- cgit v1.1