OSDN Git Service

[Support] Fix prefix logic in WithColor.
authorJonas Devlieghere <jonas@devlieghere.com>
Sun, 22 Apr 2018 08:01:01 +0000 (08:01 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Sun, 22 Apr 2018 08:01:01 +0000 (08:01 +0000)
When a prefix is passed, we need to print a colon a space after it, not
just the prefix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330535 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/WithColor.cpp

index c3ab35b..a663c69 100644 (file)
@@ -66,17 +66,20 @@ raw_ostream &WithColor::warning() { return warning(errs()); }
 raw_ostream &WithColor::note() { return note(errs()); }
 
 raw_ostream &WithColor::error(raw_ostream &OS, StringRef Prefix) {
-  OS << Prefix;
+  if (!Prefix.empty())
+    OS << Prefix << ": ";
   return WithColor(OS, HighlightColor::Error).get() << "error: ";
 }
 
 raw_ostream &WithColor::warning(raw_ostream &OS, StringRef Prefix) {
-  OS << Prefix;
+  if (!Prefix.empty())
+    OS << Prefix << ": ";
   return WithColor(OS, HighlightColor::Warning).get() << "warning: ";
 }
 
 raw_ostream &WithColor::note(raw_ostream &OS, StringRef Prefix) {
-  OS << Prefix;
+  if (!Prefix.empty())
+    OS << Prefix << ": ";
   return WithColor(OS, HighlightColor::Note).get() << "note: ";
 }