summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-02-27 22:11:43 +0000
committerZachary Turner <zturner@google.com>2017-02-27 22:11:43 +0000
commit120faca41bddd3a5922bdefbeb7c68908fda9ab9 (patch)
treee3c36b67c61a5021ed8847241cfaf9c59b48309a /llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
parent4a7cc16e89b68d48335e7cd19837c3e67e12afb2 (diff)
downloadbcm5719-llvm-120faca41bddd3a5922bdefbeb7c68908fda9ab9.tar.gz
bcm5719-llvm-120faca41bddd3a5922bdefbeb7c68908fda9ab9.zip
[PDB] Partial resubmit of r296215, which improved PDB Stream Library.
This was reverted because it was breaking some builds, and because of incorrect error code usage. Since the CL was large and contained many different things, I'm resubmitting it in pieces. This portion is NFC, and consists of: 1) Renaming classes to follow a consistent naming convention. 2) Fixing the const-ness of the interface methods. 3) Adding detailed doxygen comments. 4) Fixing a few instances of passing `const BinaryStream& X`. These are now passed as `BinaryStreamRef X`. llvm-svn: 296394
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
index 60687ac23b0..f8d44320889 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
@@ -153,18 +153,18 @@ Error DbiStreamBuilder::generateModiSubstream() {
uint32_t Size = calculateModiSubstreamSize();
auto Data = Allocator.Allocate<uint8_t>(Size);
- ModInfoBuffer = MutableByteStream(MutableArrayRef<uint8_t>(Data, Size));
+ ModInfoBuffer = MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size));
- StreamWriter ModiWriter(ModInfoBuffer);
+ BinaryStreamWriter ModiWriter(ModInfoBuffer);
for (const auto &M : ModuleInfoList) {
ModuleInfoHeader Layout = {};
Layout.ModDiStream = kInvalidStreamIndex;
Layout.NumFiles = M->SourceFiles.size();
if (auto EC = ModiWriter.writeObject(Layout))
return EC;
- if (auto EC = ModiWriter.writeZeroString(M->Mod))
+ if (auto EC = ModiWriter.writeCString(M->Mod))
return EC;
- if (auto EC = ModiWriter.writeZeroString(M->Obj))
+ if (auto EC = ModiWriter.writeCString(M->Obj))
return EC;
}
if (ModiWriter.bytesRemaining() > sizeof(uint32_t))
@@ -179,11 +179,12 @@ Error DbiStreamBuilder::generateFileInfoSubstream() {
auto Data = Allocator.Allocate<uint8_t>(Size);
uint32_t NamesOffset = Size - NameSize;
- FileInfoBuffer = MutableByteStream(MutableArrayRef<uint8_t>(Data, Size));
+ FileInfoBuffer =
+ MutableBinaryByteStream(MutableArrayRef<uint8_t>(Data, Size));
- WritableStreamRef MetadataBuffer =
- WritableStreamRef(FileInfoBuffer).keep_front(NamesOffset);
- StreamWriter MetadataWriter(MetadataBuffer);
+ WritableBinaryStreamRef MetadataBuffer =
+ WritableBinaryStreamRef(FileInfoBuffer).keep_front(NamesOffset);
+ BinaryStreamWriter MetadataWriter(MetadataBuffer);
uint16_t ModiCount = std::min<uint32_t>(UINT16_MAX, ModuleInfos.size());
uint16_t FileCount = std::min<uint32_t>(UINT16_MAX, SourceFileNames.size());
@@ -209,11 +210,11 @@ Error DbiStreamBuilder::generateFileInfoSubstream() {
// A side effect of this is that this will actually compute the various
// file name offsets, so we can then go back and write the FileNameOffsets
// array to the other substream.
- NamesBuffer = WritableStreamRef(FileInfoBuffer).drop_front(NamesOffset);
- StreamWriter NameBufferWriter(NamesBuffer);
+ NamesBuffer = WritableBinaryStreamRef(FileInfoBuffer).drop_front(NamesOffset);
+ BinaryStreamWriter NameBufferWriter(NamesBuffer);
for (auto &Name : SourceFileNames) {
Name.second = NameBufferWriter.getOffset();
- if (auto EC = NameBufferWriter.writeZeroString(Name.getKey()))
+ if (auto EC = NameBufferWriter.writeCString(Name.getKey()))
return EC;
}
@@ -363,14 +364,14 @@ std::vector<SecMapEntry> DbiStreamBuilder::createSectionMap(
}
Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
- const msf::WritableStream &Buffer) {
+ WritableBinaryStreamRef Buffer) {
if (auto EC = finalize())
return EC;
auto InfoS =
WritableMappedBlockStream::createIndexedStream(Layout, Buffer, StreamDBI);
- StreamWriter Writer(*InfoS);
+ BinaryStreamWriter Writer(*InfoS);
if (auto EC = Writer.writeObject(*Header))
return EC;
@@ -404,9 +405,9 @@ Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
for (auto &Stream : DbgStreams) {
if (Stream.StreamNumber == kInvalidStreamIndex)
continue;
- auto WritableStream = WritableMappedBlockStream::createIndexedStream(
+ auto WritableBinaryStream = WritableMappedBlockStream::createIndexedStream(
Layout, Buffer, Stream.StreamNumber);
- StreamWriter DbgStreamWriter(*WritableStream);
+ BinaryStreamWriter DbgStreamWriter(*WritableBinaryStream);
if (auto EC = DbgStreamWriter.writeArray(Stream.Data))
return EC;
}
OpenPOWER on IntegriCloud