From 4ab3343fe5263ea37e300c57c40dc75ded6430c3 Mon Sep 17 00:00:00 2001 From: Joao Matos <joao@tritao.eu> Date: Fri, 15 Feb 2019 21:42:07 +0000 Subject: [PATCH] Use `takeError()` when handling errors in parsing libraries. --- src/CppParser/Parser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index 6de46bfd..6fed223f 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -4389,9 +4389,11 @@ ParserResult* Parser::ParseLibrary(const std::string& File) auto BinaryOrErr = llvm::object::createBinary(FileEntry); if (!BinaryOrErr) { + auto Error = BinaryOrErr.takeError(); res->kind = ParserResultKind::Error; return res; } + auto OwningBinary = std::move(BinaryOrErr.get()); auto Bin = OwningBinary.getBinary(); if (auto Archive = llvm::dyn_cast<llvm::object::Archive>(Bin)) { @@ -4399,12 +4401,14 @@ ParserResult* Parser::ParseLibrary(const std::string& File) if (res->kind == ParserResultKind::Success) return res; } + if (auto ObjectFile = llvm::dyn_cast<llvm::object::ObjectFile>(Bin)) { res->kind = ParseSharedLib(File, ObjectFile, res->library); if (res->kind == ParserResultKind::Success) return res; } + res->kind = ParserResultKind::Error; return res; }