1
0
mirror of https://github.com/RPCS3/llvm.git synced 2025-03-05 09:09:23 +00:00

[llvm-profdata] Use WithColor for printing errors

Use convenience helpers in WithColor to print errors and warnings.

Differential revision: https://reviews.llvm.org/D45658

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jonas Devlieghere 2018-04-18 14:42:33 +00:00
parent 22942f7d6c
commit 331449e7a8

@ -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());