[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.

llvm-svn: 330094
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 73aa501..ba7aef37 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -1196,14 +1196,8 @@
   return NumErrors == 0;
 }
 
-raw_ostream &DWARFVerifier::error() const {
-  return WithColor(OS, HighlightColor::Error).get() << "error: ";
-}
+raw_ostream &DWARFVerifier::error() const { return WithColor::error(OS); }
 
-raw_ostream &DWARFVerifier::warn() const {
-  return WithColor(OS, HighlightColor::Warning).get() << "warning: ";
-}
+raw_ostream &DWARFVerifier::warn() const { return WithColor::warning(OS); }
 
-raw_ostream &DWARFVerifier::note() const {
-  return WithColor(OS, HighlightColor::Note).get() << "note: ";
-}
+raw_ostream &DWARFVerifier::note() const { return WithColor::note(OS); }
diff --git a/llvm/lib/Support/WithColor.cpp b/llvm/lib/Support/WithColor.cpp
index 29fa164..5a1364f 100644
--- a/llvm/lib/Support/WithColor.cpp
+++ b/llvm/lib/Support/WithColor.cpp
@@ -59,16 +59,22 @@
   }
 }
 
-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() {