llvm.org GIT mirror llvm / 331449e
[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 Jonas Devlieghere 1 year, 5 months ago
1 changed file(s) with 12 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2626 #include "llvm/Support/InitLLVM.h"
2727 #include "llvm/Support/MemoryBuffer.h"
2828 #include "llvm/Support/Path.h"
29 #include "llvm/Support/WithColor.h"
2930 #include "llvm/Support/ThreadPool.h"
3031 #include "llvm/Support/raw_ostream.h"
3132 #include
3435
3536 enum ProfileFormat { PF_None = 0, PF_Text, PF_Binary, PF_GCC };
3637
37 static void warn(StringRef Prefix, Twine Message, std::string Whence = "",
38 static void warn(Twine Message, std::string Whence = "",
3839 std::string Hint = "") {
39 errs() << Prefix;
40 WithColor::warning();
4041 if (!Whence.empty())
4142 errs() << Whence << ": ";
4243 errs() << Message << "\n";
4344 if (!Hint.empty())
44 errs() << Hint << "\n";
45 WithColor::note() << Hint << "\n";
4546 }
4647
4748 static void exitWithError(Twine Message, std::string Whence = "",
4849 std::string Hint = "") {
49 warn("error: ", Message, Whence, Hint);
50 WithColor::error();
51 if (!Whence.empty())
52 errs() << Whence << ": ";
53 errs() << Message << "\n";
54 if (!Hint.empty())
55 WithColor::note() << Hint << "\n";
5056 ::exit(1);
5157 }
5258
295301 if (isFatalError(IPE))
296302 exitWithError(make_error(IPE), WC->ErrWhence);
297303 else
298 warn("warning: ", toString(make_error(IPE)),
304 warn(toString(make_error(IPE)),
299305 WC->ErrWhence);
300306 }
301307
784790 exitWithErrorCode(EC, OutputFilename);
785791
786792 if (ShowAllFunctions && !ShowFunction.empty())
787 errs() << "warning: -function argument ignored: showing all functions\n";
793 WithColor::warning() << "-function argument ignored: showing all functions\n";
788794
789795 std::vector Cutoffs(DetailedSummaryCutoffs.begin(),
790796 DetailedSummaryCutoffs.end());