Skip to content

Commit

Permalink
[llvm-objdump] Simplify reportError() and prepend outs().flush()
Browse files Browse the repository at this point in the history
As noticed by dblaikie.

I don't know what code paths using reportError can cause stdout output
to be interleaved with stderr, so no test is added now.

Also drop an unneeded use of errs().fflush() in reportWarning().
I requested this in D64165.
  • Loading branch information
MaskRay committed May 31, 2020
1 parent 07e8a78 commit a23d1e9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Expand Up @@ -420,10 +420,10 @@ void reportWarning(Twine Message, StringRef File) {
outs().flush();
WithColor::warning(errs(), ToolName)
<< "'" << File << "': " << Message << "\n";
errs().flush();
}

LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Twine Message) {
outs().flush();
WithColor::error(errs(), ToolName) << "'" << File << "': " << Message << "\n";
exit(1);
}
Expand All @@ -432,18 +432,16 @@ LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef FileName,
StringRef ArchiveName,
StringRef ArchitectureName) {
assert(E);
outs().flush();
WithColor::error(errs(), ToolName);
if (ArchiveName != "")
errs() << ArchiveName << "(" << FileName << ")";
else
errs() << "'" << FileName << "'";
if (!ArchitectureName.empty())
errs() << " (for architecture " << ArchitectureName << ")";
std::string Buf;
raw_string_ostream OS(Buf);
logAllUnhandledErrors(std::move(E), OS);
OS.flush();
errs() << ": " << Buf;
errs() << ": ";
logAllUnhandledErrors(std::move(E), errs());
exit(1);
}

Expand Down

0 comments on commit a23d1e9

Please sign in to comment.