diff --git a/llvm/test/tools/llvm-objcopy/strip-group-symbol.test b/llvm/test/tools/llvm-objcopy/strip-group-symbol.test index 32ef61fd70d9..0699a9f5476d 100644 --- a/llvm/test/tools/llvm-objcopy/strip-group-symbol.test +++ b/llvm/test/tools/llvm-objcopy/strip-group-symbol.test @@ -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]. diff --git a/llvm/test/tools/llvm-objcopy/strip-reloc-symbol.test b/llvm/test/tools/llvm-objcopy/strip-reloc-symbol.test index 0bf4db32ecb3..b4924059cedf 100644 --- a/llvm/test/tools/llvm-objcopy/strip-reloc-symbol.test +++ b/llvm/test/tools/llvm-objcopy/strip-reloc-symbol.test @@ -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. diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp index c727c11f91e5..616de86b15d4 100644 --- a/llvm/tools/llvm-objcopy/Object.cpp +++ b/llvm/tools/llvm-objcopy/Object.cpp @@ -433,7 +433,7 @@ void RelocationSection::removeSymbols( function_ref 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"); } diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 92b882ae6495..8d7413f4001b 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -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 #include @@ -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); }