Skip to content

Commit 2f9b2eb

Browse files
committed
[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 llvm-svn: 371895
1 parent cb9216b commit 2f9b2eb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/tools/llvm-opt-report/OptReport.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,17 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
158158
if (!Format) {
159159
handleAllErrors(Format.takeError(), [&](const ErrorInfoBase &PE) {
160160
PE.log(WithColor::error());
161-
WithColor::error() << '\n';
161+
errs() << '\n';
162162
});
163163
return false;
164164
}
165165

166166
Expected<std::unique_ptr<remarks::RemarkParser>> MaybeParser =
167-
remarks::createRemarkParser(*Format, (*Buf)->getBuffer());
167+
remarks::createRemarkParserFromMeta(*Format, (*Buf)->getBuffer());
168168
if (!MaybeParser) {
169169
handleAllErrors(MaybeParser.takeError(), [&](const ErrorInfoBase &PE) {
170170
PE.log(WithColor::error());
171+
errs() << '\n';
171172
});
172173
return false;
173174
}
@@ -182,8 +183,9 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
182183
consumeError(std::move(E));
183184
break;
184185
}
185-
handleAllErrors(MaybeRemark.takeError(), [&](const ErrorInfoBase &PE) {
186+
handleAllErrors(std::move(E), [&](const ErrorInfoBase &PE) {
186187
PE.log(WithColor::error());
188+
errs() << '\n';
187189
});
188190
return false;
189191
}

0 commit comments

Comments
 (0)