[Support] Extend WithColor helpers

Although printing warnings and errors to stderr is by far the most
common case, this patch makes it possible to specify any stream.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330094 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jonas Devlieghere
2018-04-15 08:44:15 +00:00
parent 68232226c4
commit 5365e8b418
3 changed files with 22 additions and 17 deletions
+12 -6
View File
@@ -59,16 +59,22 @@ WithColor::WithColor(raw_ostream &OS, HighlightColor Color) : OS(OS) {
}
}
raw_ostream &WithColor::error() {
return WithColor(errs(), HighlightColor::Error).get() << "error: ";
raw_ostream &WithColor::error() { return error(errs()); }
raw_ostream &WithColor::warning() { return warning(errs()); }
raw_ostream &WithColor::note() { return note(errs()); }
raw_ostream &WithColor::error(raw_ostream &OS) {
return WithColor(OS, HighlightColor::Error).get() << "error: ";
}
raw_ostream &WithColor::warning() {
return WithColor(errs(), HighlightColor::Warning).get() << "warning: ";
raw_ostream &WithColor::warning(raw_ostream &OS) {
return WithColor(OS, HighlightColor::Warning).get() << "warning: ";
}
raw_ostream &WithColor::note() {
return WithColor(errs(), HighlightColor::Note).get() << "note: ";
raw_ostream &WithColor::note(raw_ostream &OS) {
return WithColor(OS, HighlightColor::Note).get() << "note: ";
}
WithColor::~WithColor() {