[llvm] r346602 - [llvm-cxxdump] Use error reporting helpers from support

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 10 17:24:02 PST 2018


Author: jdevlieghere
Date: Sat Nov 10 17:24:02 2018
New Revision: 346602

URL: http://llvm.org/viewvc/llvm-project?rev=346602&view=rev
Log:
[llvm-cxxdump] Use error reporting helpers from support

This patch makes llvm-cxxdump use the error reporting helpers from
Support/WithColor.h

Modified:
    llvm/trunk/test/tools/llvm-cxxdump/trivial.test
    llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp

Modified: llvm/trunk/test/tools/llvm-cxxdump/trivial.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cxxdump/trivial.test?rev=346602&r1=346601&r2=346602&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cxxdump/trivial.test (original)
+++ llvm/trunk/test/tools/llvm-cxxdump/trivial.test Sat Nov 10 17:24:02 2018
@@ -63,4 +63,4 @@ ELF-I386-NEXT: _ZTV1A[8]: _ZN1A1fEv
 MIXEDARCOFF-I386:      ??_7S@@6B@[0]: ??_R4S@@6B@
 
 RUN: not llvm-cxxdump %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s
-ENOENT: {{.*}}.blah: {{[Nn]}}o such file or directory
+ENOENT: {{.*}}.blah: error: {{[Nn]}}o such file or directory

Modified: llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp?rev=346602&r1=346601&r2=346602&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp (original)
+++ llvm/trunk/tools/llvm-cxxdump/llvm-cxxdump.cpp Sat Nov 10 17:24:02 2018
@@ -23,6 +23,7 @@
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <map>
 #include <string>
@@ -43,17 +44,17 @@ namespace llvm {
 static void error(std::error_code EC) {
   if (!EC)
     return;
-  outs() << "\nError reading file: " << EC.message() << ".\n";
+  WithColor::error(outs(), "") << "reading file: " << EC.message() << ".\n";
   outs().flush();
   exit(1);
 }
 
 static void error(Error Err) {
-  if (Err) {
-    logAllUnhandledErrors(std::move(Err), outs(), "Error reading file: ");
-    outs().flush();
-    exit(1);
-  }
+  if (!Err)
+    return;
+  logAllUnhandledErrors(std::move(Err), WithColor::error(outs(), ""), "reading file: ");
+  outs().flush();
+  exit(1);
 }
 
 } // namespace llvm
@@ -61,7 +62,7 @@ static void error(Error Err) {
 static void reportError(StringRef Input, StringRef Message) {
   if (Input == "-")
     Input = "<stdin>";
-  errs() << Input << ": " << Message << "\n";
+  WithColor::error(errs(), Input) << Message << "\n";
   errs().flush();
   exit(1);
 }




More information about the llvm-commits mailing list