[llvm] r346624 - [llvm-nm] Use WithColor for error reporting
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 11 14:12:21 PST 2018
Author: jdevlieghere
Date: Sun Nov 11 14:12:21 2018
New Revision: 346624
URL: http://llvm.org/viewvc/llvm-project?rev=346624&view=rev
Log:
[llvm-nm] Use WithColor for error reporting
Use helpers from Support/WithError.h to print errors.
Modified:
llvm/trunk/test/tools/llvm-nm/ARM/macho-print-size.test
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/test/tools/llvm-nm/ARM/macho-print-size.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/ARM/macho-print-size.test?rev=346624&r1=346623&r2=346624&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/ARM/macho-print-size.test (original)
+++ llvm/trunk/test/tools/llvm-nm/ARM/macho-print-size.test Sun Nov 11 14:12:21 2018
@@ -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.
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=346624&r1=346623&r2=346624&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Sun Nov 11 14:12:21 2018
@@ -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 <vector>
@@ -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, Tw
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<StringRef> 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, StringR
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:
}
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
if (!MachOPrintSizeWarning && PrintSize && isa<MachOObjectFile>(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:
}
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&Bin)) {
if (!MachOPrintSizeWarning && PrintSize && isa<MachOObjectFile>(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))
More information about the llvm-commits
mailing list