diff --git a/test/tools/llvm-nm/ARM/macho-print-size.test b/test/tools/llvm-nm/ARM/macho-print-size.test index 98784587ee7..5a8517a9012 100644 --- a/test/tools/llvm-nm/ARM/macho-print-size.test +++ b/test/tools/llvm-nm/ARM/macho-print-size.test @@ -1,3 +1,3 @@ @ RUN: llvm-nm -print-size -arch armv7m %p/Inputs/print-size.macho-armv7m 2>&1 | FileCheck %s -@ CHECK: warning sizes with -print-size for Mach-O files are always zero. +@ CHECK: warning: sizes with -print-size for Mach-O files are always zero. diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index a30a71ac6a0..ad0afd4b0aa 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -38,6 +38,7 @@ #include "llvm/Support/Program.h" #include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include @@ -196,7 +197,7 @@ std::string ToolName; static void error(Twine Message, Twine Path = Twine()) { HadError = true; - errs() << ToolName << ": " << Path << ": " << Message << ".\n"; + WithColor::error(errs(), ToolName) << Path << ": " << Message << ".\n"; } static bool error(std::error_code EC, Twine Path = Twine()) { @@ -213,7 +214,7 @@ static bool error(std::error_code EC, Twine Path = Twine()) { static void error(llvm::Error E, StringRef FileName, const Archive::Child &C, StringRef ArchitectureName = StringRef()) { HadError = true; - errs() << ToolName << ": " << FileName; + WithColor::error(errs(), ToolName) << FileName; Expected NameOrErr = C.getName(); // TODO: if we have a error getting the name then it would be nice to print @@ -242,7 +243,7 @@ static void error(llvm::Error E, StringRef FileName, const Archive::Child &C, static void error(llvm::Error E, StringRef FileName, StringRef ArchitectureName = StringRef()) { HadError = true; - errs() << ToolName << ": " << FileName; + WithColor::error(errs(), ToolName) << FileName; if (!ArchitectureName.empty()) errs() << " (for architecture " << ArchitectureName << ") "; @@ -1775,8 +1776,8 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } if (SymbolicFile *O = dyn_cast(&*ChildOrErr.get())) { if (!MachOPrintSizeWarning && PrintSize && isa(O)) { - errs() << ToolName << ": warning sizes with -print-size for Mach-O " - "files are always zero.\n"; + WithColor::warning(errs(), ToolName) + << "sizes with -print-size for Mach-O files are always zero.\n"; MachOPrintSizeWarning = true; } if (!checkMachOAndArchFlags(O, Filename)) @@ -2016,8 +2017,8 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } if (SymbolicFile *O = dyn_cast(&Bin)) { if (!MachOPrintSizeWarning && PrintSize && isa(O)) { - errs() << ToolName << ": warning sizes with -print-size for Mach-O files " - "are always zero.\n"; + WithColor::warning(errs(), ToolName) + << "sizes with -print-size for Mach-O files are always zero.\n"; MachOPrintSizeWarning = true; } if (!checkMachOAndArchFlags(O, Filename))