Explorar o código

[llvm-cxxdump] Use error reporting helpers from support

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346602 91177308-0d34-0410-b5e6-96231b3b80d8
Jonas Devlieghere %!s(int64=6) %!d(string=hai) anos
pai
achega
bb2ce32a5b

+ 1 - 1
test/tools/llvm-cxxdump/trivial.test

@@ -63,4 +63,4 @@ ELF-I386-NEXT: _ZTV1A[8]: _ZN1A1fEv
 MIXEDARCOFF-I386:      ??_7S@@6B@[0]: ??_R4S@@6B@
 MIXEDARCOFF-I386:      ??_7S@@6B@[0]: ??_R4S@@6B@
 
 
 RUN: not llvm-cxxdump %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s
 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

+ 8 - 7
tools/llvm-cxxdump/llvm-cxxdump.cpp

@@ -23,6 +23,7 @@
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
 #include <map>
 #include <map>
 #include <string>
 #include <string>
@@ -43,17 +44,17 @@ namespace llvm {
 static void error(std::error_code EC) {
 static void error(std::error_code EC) {
   if (!EC)
   if (!EC)
     return;
     return;
-  outs() << "\nError reading file: " << EC.message() << ".\n";
+  WithColor::error(outs(), "") << "reading file: " << EC.message() << ".\n";
   outs().flush();
   outs().flush();
   exit(1);
   exit(1);
 }
 }
 
 
 static void error(Error Err) {
 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
 } // namespace llvm
@@ -61,7 +62,7 @@ static void error(Error Err) {
 static void reportError(StringRef Input, StringRef Message) {
 static void reportError(StringRef Input, StringRef Message) {
   if (Input == "-")
   if (Input == "-")
     Input = "<stdin>";
     Input = "<stdin>";
-  errs() << Input << ": " << Message << "\n";
+  WithColor::error(errs(), Input) << Message << "\n";
   errs().flush();
   errs().flush();
   exit(1);
   exit(1);
 }
 }