[llvm] r330526 - [Support] Add optional prefix to convenience helpers in WithColor.
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 21 14:36:11 PDT 2018
Author: jdevlieghere
Date: Sat Apr 21 14:36:11 2018
New Revision: 330526
URL: http://llvm.org/viewvc/llvm-project?rev=330526&view=rev
Log:
[Support] Add optional prefix to convenience helpers in WithColor.
Several tools prefix the error/warning/note output with the name of the
tool. One such tool is LLD for example. This commit adds as an optional
'Prefix' argument to the convenience helpers.
Modified:
llvm/trunk/include/llvm/Support/WithColor.h
llvm/trunk/lib/Support/WithColor.cpp
Modified: llvm/trunk/include/llvm/Support/WithColor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/WithColor.h?rev=330526&r1=330525&r2=330526&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/WithColor.h (original)
+++ llvm/trunk/include/llvm/Support/WithColor.h Sat Apr 21 14:36:11 2018
@@ -10,6 +10,8 @@
#ifndef LLVM_SUPPORT_WITHCOLOR_H
#define LLVM_SUPPORT_WITHCOLOR_H
+#include "llvm/ADT/StringRef.h"
+
namespace llvm {
class raw_ostream;
@@ -50,11 +52,11 @@ public:
static raw_ostream ¬e();
/// Convenience method for printing "error: " to the given stream.
- static raw_ostream &error(raw_ostream &OS);
+ static raw_ostream &error(raw_ostream &OS, StringRef Prefix = "");
/// Convenience method for printing "warning: " to the given stream.
- static raw_ostream &warning(raw_ostream &OS);
+ static raw_ostream &warning(raw_ostream &OS, StringRef Prefix = "");
/// Convenience method for printing "note: " to the given stream.
- static raw_ostream ¬e(raw_ostream &OS);
+ static raw_ostream ¬e(raw_ostream &OS, StringRef Prefix = "");
};
} // end namespace llvm
Modified: llvm/trunk/lib/Support/WithColor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/WithColor.cpp?rev=330526&r1=330525&r2=330526&view=diff
==============================================================================
--- llvm/trunk/lib/Support/WithColor.cpp (original)
+++ llvm/trunk/lib/Support/WithColor.cpp Sat Apr 21 14:36:11 2018
@@ -65,15 +65,18 @@ raw_ostream &WithColor::warning() { retu
raw_ostream &WithColor::note() { return note(errs()); }
-raw_ostream &WithColor::error(raw_ostream &OS) {
+raw_ostream &WithColor::error(raw_ostream &OS, StringRef Prefix) {
+ OS << Prefix;
return WithColor(OS, HighlightColor::Error).get() << "error: ";
}
-raw_ostream &WithColor::warning(raw_ostream &OS) {
+raw_ostream &WithColor::warning(raw_ostream &OS, StringRef Prefix) {
+ OS << Prefix;
return WithColor(OS, HighlightColor::Warning).get() << "warning: ";
}
-raw_ostream &WithColor::note(raw_ostream &OS) {
+raw_ostream &WithColor::note(raw_ostream &OS, StringRef Prefix) {
+ OS << Prefix;
return WithColor(OS, HighlightColor::Note).get() << "note: ";
}
More information about the llvm-commits
mailing list