diff options
Diffstat (limited to 'tools/llvm-symbolizer/LLVMSymbolize.cpp')
-rw-r--r-- | tools/llvm-symbolizer/LLVMSymbolize.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp index 3e71111..c1d39ef 100644 --- a/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/DataExtractor.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -28,7 +29,7 @@ namespace llvm { namespace symbolize { -static bool error(error_code ec) { +static bool error(std::error_code ec) { if (!ec) return false; errs() << "LLVMSymbolizer: error reading file: " << ec.message() << ".\n"; @@ -219,10 +220,11 @@ static std::string getDarwinDWARFResourceForPath(const std::string &Path) { } static bool checkFileCRC(StringRef Path, uint32_t CRCHash) { - std::unique_ptr<MemoryBuffer> MB; - if (MemoryBuffer::getFileOrSTDIN(Path, MB)) + ErrorOr<std::unique_ptr<MemoryBuffer>> MB = + MemoryBuffer::getFileOrSTDIN(Path); + if (!MB) return false; - return !zlib::isAvailable() || CRCHash == zlib::crc32(MB->getBuffer()); + return !zlib::isAvailable() || CRCHash == zlib::crc32(MB.get()->getBuffer()); } static bool findDebugBinary(const std::string &OrigPath, @@ -310,7 +312,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { const std::string &ResourcePath = getDarwinDWARFResourceForPath(Path); BinaryOrErr = createBinary(ResourcePath); - error_code EC = BinaryOrErr.getError(); + std::error_code EC = BinaryOrErr.getError(); if (EC != errc::no_such_file_or_directory && !error(EC)) { DbgBin = BinaryOrErr.get(); ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin)); @@ -348,10 +350,11 @@ LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName std::make_pair(UB, ArchName)); if (I != ObjectFileForArch.end()) return I->second; - std::unique_ptr<ObjectFile> ParsedObj; - if (!UB->getObjectForArch(Triple(ArchName).getArch(), ParsedObj)) { - Res = ParsedObj.get(); - ParsedBinariesAndObjects.push_back(std::move(ParsedObj)); + ErrorOr<std::unique_ptr<ObjectFile>> ParsedObj = + UB->getObjectForArch(Triple(ArchName).getArch()); + if (ParsedObj) { + Res = ParsedObj.get().get(); + ParsedBinariesAndObjects.push_back(std::move(ParsedObj.get())); } ObjectFileForArch[std::make_pair(UB, ArchName)] = Res; } else if (Bin->isObject()) { |