From bb2ce32a5bd58ea01d609989fc47276b323e184e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 11 Nov 2018 01:24:02 +0000 Subject: [PATCH] [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 --- test/tools/llvm-cxxdump/trivial.test | 2 +- tools/llvm-cxxdump/llvm-cxxdump.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/tools/llvm-cxxdump/trivial.test b/test/tools/llvm-cxxdump/trivial.test index d4982b87d8d..8df0bc32e1e 100644 --- a/test/tools/llvm-cxxdump/trivial.test +++ b/test/tools/llvm-cxxdump/trivial.test @@ -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 diff --git a/tools/llvm-cxxdump/llvm-cxxdump.cpp b/tools/llvm-cxxdump/llvm-cxxdump.cpp index 09e40d9b0db..40db5c933f0 100644 --- a/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -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 #include @@ -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 = ""; - errs() << Input << ": " << Message << "\n"; + WithColor::error(errs(), Input) << Message << "\n"; errs().flush(); exit(1); } -- 2.11.0