From eb11fae6d08f479c0799db45860a98af528fa6e7 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 28 Jul 2018 10:51:19 +0000 Subject: Vendor import of llvm trunk r338150: https://llvm.org/svn/llvm-project/llvm/trunk@338150 --- lib/DebugInfo/PDB/Native/PDBFile.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/DebugInfo/PDB/Native/PDBFile.cpp') diff --git a/lib/DebugInfo/PDB/Native/PDBFile.cpp b/lib/DebugInfo/PDB/Native/PDBFile.cpp index 15b31d821b1c..78b11937f051 100644 --- a/lib/DebugInfo/PDB/Native/PDBFile.cpp +++ b/lib/DebugInfo/PDB/Native/PDBFile.cpp @@ -289,8 +289,8 @@ Expected PDBFile::getPDBDbiStream() { auto DbiS = safelyCreateIndexedStream(ContainerLayout, *Buffer, StreamDBI); if (!DbiS) return DbiS.takeError(); - auto TempDbi = llvm::make_unique(*this, std::move(*DbiS)); - if (auto EC = TempDbi->reload()) + auto TempDbi = llvm::make_unique(std::move(*DbiS)); + if (auto EC = TempDbi->reload(this)) return std::move(EC); Dbi = std::move(TempDbi); } @@ -370,7 +370,10 @@ Expected PDBFile::getStringTable() { if (!IS) return IS.takeError(); - uint32_t NameStreamIndex = IS->getNamedStreamIndex("/names"); + Expected ExpectedNSI = IS->getNamedStreamIndex("/names"); + if (!ExpectedNSI) + return ExpectedNSI.takeError(); + uint32_t NameStreamIndex = *ExpectedNSI; auto NS = safelyCreateIndexedStream(ContainerLayout, *Buffer, NameStreamIndex); @@ -445,7 +448,13 @@ bool PDBFile::hasPDBStringTable() { auto IS = getPDBInfoStream(); if (!IS) return false; - return IS->getNamedStreamIndex("/names") < getNumStreams(); + Expected ExpectedNSI = IS->getNamedStreamIndex("/names"); + if (!ExpectedNSI) { + consumeError(ExpectedNSI.takeError()); + return false; + } + assert(*ExpectedNSI < getNumStreams()); + return true; } /// Wrapper around MappedBlockStream::createIndexedStream() that checks if a -- cgit v1.3