From 7ab0a1882b2587a59be344e7ce1f873fdd7ce6e8 Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Fri, 13 Sep 2019 20:52:04 +0000 Subject: [PATCH] [llvm-opt-report] Improve error handling * std::move the error extracted from the parsing creation to avoid asserts * print a newline after the error message * create the parser from the metadata git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371895 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-opt-report/OptReport.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/llvm-opt-report/OptReport.cpp b/tools/llvm-opt-report/OptReport.cpp index a0bc5dccbcf..4aecec2749e 100644 --- a/tools/llvm-opt-report/OptReport.cpp +++ b/tools/llvm-opt-report/OptReport.cpp @@ -158,16 +158,17 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { if (!Format) { handleAllErrors(Format.takeError(), [&](const ErrorInfoBase &PE) { PE.log(WithColor::error()); - WithColor::error() << '\n'; + errs() << '\n'; }); return false; } Expected> MaybeParser = - remarks::createRemarkParser(*Format, (*Buf)->getBuffer()); + remarks::createRemarkParserFromMeta(*Format, (*Buf)->getBuffer()); if (!MaybeParser) { handleAllErrors(MaybeParser.takeError(), [&](const ErrorInfoBase &PE) { PE.log(WithColor::error()); + errs() << '\n'; }); return false; } @@ -182,8 +183,9 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { consumeError(std::move(E)); break; } - handleAllErrors(MaybeRemark.takeError(), [&](const ErrorInfoBase &PE) { + handleAllErrors(std::move(E), [&](const ErrorInfoBase &PE) { PE.log(WithColor::error()); + errs() << '\n'; }); return false; } -- 2.40.0