From 90d4a1bb6fae123c643bc0e50310c07bb6e01068 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 7 Jun 2016 20:38:37 +0000 Subject: [PATCH] [pdb] Convert StringRefs to ArrayRefs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272058 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/PDB/Raw/IPDBFile.h | 4 ++-- include/llvm/DebugInfo/PDB/Raw/PDBFile.h | 3 ++- lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp | 11 +++++------ lib/DebugInfo/PDB/Raw/PDBFile.cpp | 9 ++++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h b/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h index a772ef1a7ae..0f8736d55c4 100644 --- a/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h +++ b/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h @@ -32,8 +32,8 @@ public: virtual ArrayRef getStreamBlockList(uint32_t StreamIndex) const = 0; - virtual StringRef getBlockData(uint32_t BlockIndex, - uint32_t NumBytes) const = 0; + virtual ArrayRef getBlockData(uint32_t BlockIndex, + uint32_t NumBytes) const = 0; }; } } diff --git a/include/llvm/DebugInfo/PDB/Raw/PDBFile.h b/include/llvm/DebugInfo/PDB/Raw/PDBFile.h index d3f269430a7..f6ee987adcd 100644 --- a/include/llvm/DebugInfo/PDB/Raw/PDBFile.h +++ b/include/llvm/DebugInfo/PDB/Raw/PDBFile.h @@ -52,7 +52,8 @@ public: ArrayRef getStreamBlockList(uint32_t StreamIndex) const override; - StringRef getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override; + ArrayRef getBlockData(uint32_t BlockIndex, + uint32_t NumBytes) const override; ArrayRef getDirectoryBlockArray() const; diff --git a/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp b/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp index 03462b38863..3428ff83471 100644 --- a/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp +++ b/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp @@ -78,10 +78,9 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size, } uint32_t FirstBlockAddr = BlockList[BlockNum]; - StringRef Str = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize()); - Str = Str.drop_front(OffsetInBlock); - Buffer = - ArrayRef(reinterpret_cast(Str.data()), Size); + auto Data = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize()); + Data = Data.drop_front(OffsetInBlock); + Buffer = ArrayRef(Data.data(), Size); return true; } @@ -103,9 +102,9 @@ Error MappedBlockStream::readBytes(uint32_t Offset, 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); diff --git a/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/lib/DebugInfo/PDB/Raw/PDBFile.cpp index 9ef0a492e87..22094773624 100644 --- a/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -138,11 +138,14 @@ PDBFile::getStreamBlockList(uint32_t StreamIndex) const { return Array; } -StringRef PDBFile::getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const { +ArrayRef PDBFile::getBlockData(uint32_t BlockIndex, + uint32_t NumBytes) const { uint64_t StreamBlockOffset = blockToOffset(BlockIndex, getBlockSize()); - return StringRef(Context->Buffer->getBufferStart() + StreamBlockOffset, - NumBytes); + return ArrayRef( + reinterpret_cast(Context->Buffer->getBufferStart()) + + StreamBlockOffset, + NumBytes); } Error PDBFile::parseFileHeaders() { -- 2.11.0