diff options
Diffstat (limited to 'llvm/lib/DebugInfo/PDB')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp | 11 |
3 files changed, 17 insertions, 11 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp index b44a474b63d..e2edf38e594 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -36,8 +36,9 @@ namespace { typedef FixedStreamArray<support::ulittle32_t> ulittle_array; } -PDBFile::PDBFile(std::unique_ptr<StreamInterface> PdbFileBuffer) - : Buffer(std::move(PdbFileBuffer)), SB(nullptr) {} +PDBFile::PDBFile(std::unique_ptr<StreamInterface> PdbFileBuffer, + BumpPtrAllocator &Allocator) + : Allocator(Allocator), Buffer(std::move(PdbFileBuffer)), SB(nullptr) {} PDBFile::~PDBFile() {} diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp index c6bcd5106ca..6312cc25dba 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp @@ -26,12 +26,12 @@ using namespace llvm::msf; using namespace llvm::pdb; using namespace llvm::support; -PDBFileBuilder::PDBFileBuilder(std::unique_ptr<msf::StreamInterface> FileBuffer) - : File(llvm::make_unique<PDBFile>(std::move(FileBuffer))) {} +PDBFileBuilder::PDBFileBuilder(BumpPtrAllocator &Allocator) + : Allocator(Allocator) {} Error PDBFileBuilder::initialize(const msf::SuperBlock &Super) { auto ExpectedMsf = - MsfBuilder::create(File->Allocator, Super.BlockSize, Super.NumBlocks); + MsfBuilder::create(Allocator, Super.BlockSize, Super.NumBlocks); if (!ExpectedMsf) return ExpectedMsf.takeError(); @@ -54,11 +54,12 @@ InfoStreamBuilder &PDBFileBuilder::getInfoBuilder() { DbiStreamBuilder &PDBFileBuilder::getDbiBuilder() { if (!Dbi) - Dbi = llvm::make_unique<DbiStreamBuilder>(File->Allocator); + Dbi = llvm::make_unique<DbiStreamBuilder>(Allocator); return *Dbi; } -Expected<std::unique_ptr<PDBFile>> PDBFileBuilder::build() { +Expected<std::unique_ptr<PDBFile>> +PDBFileBuilder::build(std::unique_ptr<msf::StreamInterface> PdbFileBuffer) { if (Info) { uint32_t Length = Info->calculateSerializedLength(); if (auto EC = Msf->setStreamSize(StreamPDB, Length)) @@ -74,6 +75,7 @@ Expected<std::unique_ptr<PDBFile>> PDBFileBuilder::build() { if (!ExpectedLayout) return ExpectedLayout.takeError(); + auto File = llvm::make_unique<PDBFile>(std::move(PdbFileBuffer), Allocator); const msf::Layout &L = *ExpectedLayout; File->StreamMap = L.StreamMap; File->StreamSizes = L.StreamSizes; diff --git a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp index e734aebf47f..e6d915fcaee 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/RawSession.cpp @@ -41,8 +41,9 @@ public: }; } -RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile) - : Pdb(std::move(PdbFile)) {} +RawSession::RawSession(std::unique_ptr<PDBFile> PdbFile, + std::unique_ptr<BumpPtrAllocator> Allocator) + : Pdb(std::move(PdbFile)), Allocator(std::move(Allocator)) {} RawSession::~RawSession() {} @@ -58,13 +59,15 @@ Error RawSession::createFromPdb(StringRef Path, std::unique_ptr<MemoryBuffer> Buffer = std::move(*ErrorOrBuffer); auto Stream = llvm::make_unique<InputByteStream>(std::move(Buffer)); - std::unique_ptr<PDBFile> File(new PDBFile(std::move(Stream))); + auto Allocator = llvm::make_unique<BumpPtrAllocator>(); + auto File = llvm::make_unique<PDBFile>(std::move(Stream), *Allocator); if (auto EC = File->parseFileHeaders()) return EC; if (auto EC = File->parseStreamData()) return EC; - Session.reset(new RawSession(std::move(File))); + Session = + llvm::make_unique<RawSession>(std::move(File), std::move(Allocator)); return Error::success(); } |