diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-04-18 14:42:33 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-04-18 14:42:33 +0000 |
commit | e46b7565bbaedbb0df9a5b0290560ed351d17a73 (patch) | |
tree | 9a8269a9b4f936c1f47ea3da5d8bd643ea76acd2 /llvm/tools/llvm-profdata/llvm-profdata.cpp | |
parent | fef7adae1d5ed7aadc317515b7aefeaf7f5936b8 (diff) | |
download | bcm5719-llvm-e46b7565bbaedbb0df9a5b0290560ed351d17a73.tar.gz bcm5719-llvm-e46b7565bbaedbb0df9a5b0290560ed351d17a73.zip |
[llvm-profdata] Use WithColor for printing errors
Use convenience helpers in WithColor to print errors and warnings.
Differential revision: https://reviews.llvm.org/D45658
llvm-svn: 330262
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index e993d6d91fe..cb043837134 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/InitLLVM.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" +#include "llvm/Support/WithColor.h" #include "llvm/Support/ThreadPool.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -35,19 +36,24 @@ using namespace llvm; enum ProfileFormat { PF_None = 0, PF_Text, PF_Binary, PF_GCC }; -static void warn(StringRef Prefix, Twine Message, std::string Whence = "", +static void warn(Twine Message, std::string Whence = "", std::string Hint = "") { - errs() << Prefix; + WithColor::warning(); if (!Whence.empty()) errs() << Whence << ": "; errs() << Message << "\n"; if (!Hint.empty()) - errs() << Hint << "\n"; + WithColor::note() << Hint << "\n"; } static void exitWithError(Twine Message, std::string Whence = "", std::string Hint = "") { - warn("error: ", Message, Whence, Hint); + WithColor::error(); + if (!Whence.empty()) + errs() << Whence << ": "; + errs() << Message << "\n"; + if (!Hint.empty()) + WithColor::note() << Hint << "\n"; ::exit(1); } @@ -296,7 +302,7 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, if (isFatalError(IPE)) exitWithError(make_error<InstrProfError>(IPE), WC->ErrWhence); else - warn("warning: ", toString(make_error<InstrProfError>(IPE)), + warn(toString(make_error<InstrProfError>(IPE)), WC->ErrWhence); } @@ -785,7 +791,7 @@ static int show_main(int argc, const char *argv[]) { exitWithErrorCode(EC, OutputFilename); if (ShowAllFunctions && !ShowFunction.empty()) - errs() << "warning: -function argument ignored: showing all functions\n"; + WithColor::warning() << "-function argument ignored: showing all functions\n"; std::vector<uint32_t> Cutoffs(DetailedSummaryCutoffs.begin(), DetailedSummaryCutoffs.end()); |