[llvm-objcopy] NFC: Add some color to error()

llvm-svn: 339404
This commit is contained in:
Jordan Rupprecht 2018-08-09 22:52:03 +00:00
parent 40922db37c
commit 88ed5e59bd
4 changed files with 9 additions and 6 deletions

View File

@ -28,4 +28,4 @@ Symbols:
Type: STT_FUNC
Section: .text
#CHECK: {{.*}}llvm-objcopy{{(\.EXE|\.exe)?}}: Symbol foo cannot be removed because it is referenced by the section .group[1].
#CHECK: Symbol foo cannot be removed because it is referenced by the section .group[1].

View File

@ -29,4 +29,4 @@ Symbols:
Value: 0x1000
Size: 8
#CHECK: {{.*}}llvm-objcopy{{(\.EXE|\.exe)?}}: not stripping symbol `foo' because it is named in a relocation.
#CHECK: not stripping symbol 'foo' because it is named in a relocation.

View File

@ -433,7 +433,7 @@ void RelocationSection::removeSymbols(
function_ref<bool(const Symbol &)> ToRemove) {
for (const Relocation &Reloc : Relocations)
if (ToRemove(*Reloc.RelocSymbol))
error("not stripping symbol `" + Reloc.RelocSymbol->Name +
error("not stripping symbol '" + Reloc.RelocSymbol->Name +
"' because it is named in a relocation");
}

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm-objcopy.h"
#include "Object.h"
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/Optional.h"
@ -34,6 +35,7 @@
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
@ -189,14 +191,15 @@ namespace objcopy {
StringRef ToolName;
LLVM_ATTRIBUTE_NORETURN void error(Twine Message) {
errs() << ToolName << ": " << Message << ".\n";
WithColor::error(errs(), ToolName) << Message << ".\n";
errs().flush();
exit(1);
}
LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, std::error_code EC) {
assert(EC);
errs() << ToolName << ": '" << File << "': " << EC.message() << ".\n";
WithColor::error(errs(), ToolName)
<< "'" << File << "': " << EC.message() << ".\n";
exit(1);
}
@ -206,7 +209,7 @@ LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) {
raw_string_ostream OS(Buf);
logAllUnhandledErrors(std::move(E), OS, "");
OS.flush();
errs() << ToolName << ": '" << File << "': " << Buf;
WithColor::error(errs(), ToolName) << "'" << File << "': " << Buf;
exit(1);
}