[llvm] r335415 - [TableGen] Use WithColor for printing errors/warnings

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 23 09:48:03 PDT 2018


Author: jdevlieghere
Date: Sat Jun 23 09:48:03 2018
New Revision: 335415

URL: http://llvm.org/viewvc/llvm-project?rev=335415&view=rev
Log:
[TableGen] Use WithColor for printing errors/warnings

Use the WithColor helper from support to print errors and warnings.

Modified:
    llvm/trunk/lib/TableGen/Error.cpp

Modified: llvm/trunk/lib/TableGen/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Error.cpp?rev=335415&r1=335414&r2=335415&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Error.cpp (original)
+++ llvm/trunk/lib/TableGen/Error.cpp Sat Jun 23 09:48:03 2018
@@ -15,6 +15,7 @@
 #include "llvm/TableGen/Error.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdlib>
 
@@ -51,9 +52,7 @@ void PrintWarning(const char *Loc, const
   SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Warning, Msg);
 }
 
-void PrintWarning(const Twine &Msg) {
-  errs() << "warning:" << Msg << "\n";
-}
+void PrintWarning(const Twine &Msg) { WithColor::warning() << Msg << "\n"; }
 
 void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg) {
   PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
@@ -63,9 +62,7 @@ void PrintError(const char *Loc, const T
   SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg);
 }
 
-void PrintError(const Twine &Msg) {
-  errs() << "error:" << Msg << "\n";
-}
+void PrintError(const Twine &Msg) { WithColor::error() << Msg << "\n"; }
 
 void PrintFatalError(const Twine &Msg) {
   PrintError(Msg);




More information about the llvm-commits mailing list