[PATCH] D45666: [llvm-mca] Use WithColor for printing errors

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 15 03:46:11 PDT 2018


JDevlieghere created this revision.
JDevlieghere added a reviewer: andreadb.
Herald added subscribers: gbedwell, tschuett.

Use convenience helpers in WithColor to print errors and notes.


Repository:
  rL LLVM

https://reviews.llvm.org/D45666

Files:
  llvm/tools/llvm-mca/llvm-mca.cpp


Index: llvm/tools/llvm-mca/llvm-mca.cpp
===================================================================
--- llvm/tools/llvm-mca/llvm-mca.cpp
+++ llvm/tools/llvm-mca/llvm-mca.cpp
@@ -47,6 +47,7 @@
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace llvm;
 
@@ -306,7 +307,7 @@
   ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
       MemoryBuffer::getFileOrSTDIN(InputFilename);
   if (std::error_code EC = BufferPtr.getError()) {
-    errs() << InputFilename << ": " << EC.message() << '\n';
+    WithColor::error() << InputFilename << ": " << EC.message() << '\n';
     return 1;
   }
 
@@ -337,29 +338,31 @@
     return 1;
 
   if (!STI->getSchedModel().isOutOfOrder()) {
-    errs() << "error: please specify an out-of-order cpu. '" << MCPU
-           << "' is an in-order cpu.\n";
+    WithColor::error() << "please specify an out-of-order cpu. '" << MCPU
+                       << "' is an in-order cpu.\n";
     return 1;
   }
 
   if (!STI->getSchedModel().hasInstrSchedModel()) {
-    errs()
-        << "error: unable to find instruction-level scheduling information for"
+    WithColor::error()
+        << "unable to find instruction-level scheduling information for"
         << " target triple '" << TheTriple.normalize() << "' and cpu '" << MCPU
         << "'.\n";
 
     if (STI->getSchedModel().InstrItineraries)
-      errs() << "note: cpu '" << MCPU << "' provides itineraries. However, "
-             << "instruction itineraries are currently unsupported.\n";
+      WithColor::note()
+          << "cpu '" << MCPU << "' provides itineraries. However, "
+          << "instruction itineraries are currently unsupported.\n";
     return 1;
   }
 
   std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
       Triple(TripleName), OutputAsmVariant, *MAI, *MCII, *MRI));
   if (!IP) {
-    errs() << "error: unable to create instruction printer for target triple '"
-           << TheTriple.normalize() << "' with assembly variant "
-           << OutputAsmVariant << ".\n";
+    WithColor::error()
+        << "unable to create instruction printer for target triple '"
+        << TheTriple.normalize() << "' with assembly variant "
+        << OutputAsmVariant << ".\n";
     return 1;
   }
 
@@ -372,14 +375,14 @@
     return 1;
 
   if (Regions.empty()) {
-    errs() << "error: no assembly instructions found.\n";
+    WithColor::error() << "no assembly instructions found.\n";
     return 1;
   }
 
   // Now initialize the output file.
   auto OF = getOutputStream();
   if (std::error_code EC = OF.getError()) {
-    errs() << EC.message() << '\n';
+    WithColor::error() << EC.message() << '\n';
     return 1;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45666.142552.patch
Type: text/x-patch
Size: 2797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180415/05baf086/attachment.bin>


More information about the llvm-commits mailing list