[llvm] r272058 - [pdb] Convert StringRefs to ArrayRef<uint8_t>s.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 7 13:38:37 PDT 2016
Author: zturner
Date: Tue Jun 7 15:38:37 2016
New Revision: 272058
URL: http://llvm.org/viewvc/llvm-project?rev=272058&view=rev
Log:
[pdb] Convert StringRefs to ArrayRef<uint8_t>s.
Modified:
llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h
llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h?rev=272058&r1=272057&r2=272058&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h Tue Jun 7 15:38:37 2016
@@ -32,8 +32,8 @@ public:
virtual ArrayRef<support::ulittle32_t>
getStreamBlockList(uint32_t StreamIndex) const = 0;
- virtual StringRef getBlockData(uint32_t BlockIndex,
- uint32_t NumBytes) const = 0;
+ virtual ArrayRef<uint8_t> getBlockData(uint32_t BlockIndex,
+ uint32_t NumBytes) const = 0;
};
}
}
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h?rev=272058&r1=272057&r2=272058&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h Tue Jun 7 15:38:37 2016
@@ -52,7 +52,8 @@ public:
ArrayRef<support::ulittle32_t>
getStreamBlockList(uint32_t StreamIndex) const override;
- StringRef getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override;
+ ArrayRef<uint8_t> getBlockData(uint32_t BlockIndex,
+ uint32_t NumBytes) const override;
ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp?rev=272058&r1=272057&r2=272058&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp Tue Jun 7 15:38:37 2016
@@ -78,10 +78,9 @@ bool MappedBlockStream::tryReadContiguou
}
uint32_t FirstBlockAddr = BlockList[BlockNum];
- StringRef Str = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize());
- Str = Str.drop_front(OffsetInBlock);
- Buffer =
- ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Str.data()), Size);
+ auto Data = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize());
+ Data = Data.drop_front(OffsetInBlock);
+ Buffer = ArrayRef<uint8_t>(Data.data(), Size);
return true;
}
@@ -103,9 +102,9 @@ Error MappedBlockStream::readBytes(uint3
while (BytesLeft > 0) {
uint32_t StreamBlockAddr = BlockList[BlockNum];
- StringRef Data = Pdb.getBlockData(StreamBlockAddr, Pdb.getBlockSize());
+ auto Data = Pdb.getBlockData(StreamBlockAddr, Pdb.getBlockSize());
- const char *ChunkStart = Data.data() + OffsetInBlock;
+ const uint8_t *ChunkStart = Data.data() + OffsetInBlock;
uint32_t BytesInChunk =
std::min(BytesLeft, Pdb.getBlockSize() - OffsetInBlock);
::memcpy(WriteBuffer + BytesWritten, ChunkStart, BytesInChunk);
Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp?rev=272058&r1=272057&r2=272058&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp Tue Jun 7 15:38:37 2016
@@ -138,11 +138,14 @@ PDBFile::getStreamBlockList(uint32_t Str
return Array;
}
-StringRef PDBFile::getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const {
+ArrayRef<uint8_t> PDBFile::getBlockData(uint32_t BlockIndex,
+ uint32_t NumBytes) const {
uint64_t StreamBlockOffset = blockToOffset(BlockIndex, getBlockSize());
- return StringRef(Context->Buffer->getBufferStart() + StreamBlockOffset,
- NumBytes);
+ return ArrayRef<uint8_t>(
+ reinterpret_cast<const uint8_t *>(Context->Buffer->getBufferStart()) +
+ StreamBlockOffset,
+ NumBytes);
}
Error PDBFile::parseFileHeaders() {
More information about the llvm-commits
mailing list