[PDB] General improvements to Stream library.
This adds various new functionality and cleanup surrounding the
use of the Stream library. Major changes include:
* Renaming of all classes for more consistency / meaningfulness
* Addition of some new methods for reading multiple values at once.
* Full suite of unit tests for reader / writer functionality.
* Full set of doxygen comments for all classes.
* Streams now store their own endianness.
* Fixed some bugs in a few of the classes that were discovered
by the unit tests.
llvm-svn: 296215
diff --git a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
index 29c1ec0..7d532ee 100644
--- a/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/TpiStreamBuilder.cpp
@@ -34,7 +34,8 @@
using namespace llvm::support;
TpiStreamBuilder::TpiStreamBuilder(MSFBuilder &Msf, uint32_t StreamIdx)
- : Msf(Msf), Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) {
+ : Msf(Msf), Allocator(Msf.getAllocator()),
+ TypeRecordStream(llvm::support::little), Header(nullptr), Idx(StreamIdx) {
}
TpiStreamBuilder::~TpiStreamBuilder() = default;
@@ -82,7 +83,7 @@
return Error::success();
}
-uint32_t TpiStreamBuilder::calculateSerializedLength() const {
+uint32_t TpiStreamBuilder::calculateSerializedLength() {
return sizeof(TpiStreamHeader) + TypeRecordStream.getLength();
}
@@ -113,19 +114,20 @@
}
ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(HashBuffer.data()),
HashBufferSize);
- HashValueStream = llvm::make_unique<ByteStream>(Bytes);
+ HashValueStream =
+ llvm::make_unique<BinaryByteStream>(Bytes, llvm::support::little);
return Error::success();
}
Error TpiStreamBuilder::commit(const msf::MSFLayout &Layout,
- const msf::WritableStream &Buffer) {
+ WritableBinaryStreamRef Buffer) {
if (auto EC = finalize())
return EC;
auto InfoS =
WritableMappedBlockStream::createIndexedStream(Layout, Buffer, Idx);
- StreamWriter Writer(*InfoS);
+ BinaryStreamWriter Writer(*InfoS);
if (auto EC = Writer.writeObject(*Header))
return EC;
@@ -136,7 +138,7 @@
if (HashStreamIndex != kInvalidStreamIndex) {
auto HVS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
HashStreamIndex);
- StreamWriter HW(*HVS);
+ BinaryStreamWriter HW(*HVS);
if (auto EC = HW.writeStreamRef(*HashValueStream))
return EC;
}