[llvm-commits] [llvm] r74507 - in /llvm/trunk/lib/CompilerDriver: Action.cpp CompilationGraph.cpp Main.cpp

Bill Wendling isanbard at gmail.com
Mon Jun 29 21:07:12 PDT 2009


Author: void
Date: Mon Jun 29 23:07:12 2009
New Revision: 74507

URL: http://llvm.org/viewvc/llvm-project?rev=74507&view=rev
Log:
#include <iostream> is forbidden. Remove it in favor of raw_ostream.

Modified:
    llvm/trunk/lib/CompilerDriver/Action.cpp
    llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp
    llvm/trunk/lib/CompilerDriver/Main.cpp

Modified: llvm/trunk/lib/CompilerDriver/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Action.cpp?rev=74507&r1=74506&r2=74507&view=diff

==============================================================================
--- llvm/trunk/lib/CompilerDriver/Action.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/Action.cpp Mon Jun 29 23:07:12 2009
@@ -13,10 +13,8 @@
 
 #include "llvm/CompilerDriver/Action.h"
 #include "llvm/CompilerDriver/BuiltinOptions.h"
-
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Program.h"
-
-#include <iostream>
 #include <stdexcept>
 
 using namespace llvm;
@@ -58,15 +56,15 @@
   }
 
   void print_string (const std::string& str) {
-    std::cerr << str << ' ';
+    errs() << str << ' ';
   }
 }
 
 int llvmc::Action::Execute() const {
   if (DryRun || VerboseMode) {
-    std::cerr << Command_ << " ";
+    errs() << Command_ << " ";
     std::for_each(Args_.begin(), Args_.end(), print_string);
-    std::cerr << '\n';
+    errs() << '\n';
   }
   if (DryRun)
     return 0;

Modified: llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp?rev=74507&r1=74506&r2=74507&view=diff

==============================================================================
--- llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp Mon Jun 29 23:07:12 2009
@@ -18,10 +18,10 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/DOTGraphTraits.h"
 #include "llvm/Support/GraphWriter.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include <algorithm>
 #include <cstring>
-#include <iostream>
 #include <iterator>
 #include <limits>
 #include <queue>
@@ -346,8 +346,8 @@
 
         if (!N2.ToolPtr) {
           ++ret;
-          std::cerr << "Error: there is an edge from '" << N1.ToolPtr->Name()
-                    << "' back to the root!\n\n";
+          errs() << "Error: there is an edge from '" << N1.ToolPtr->Name()
+                 << "' back to the root!\n\n";
           continue;
         }
 
@@ -363,17 +363,17 @@
 
         if (!eq) {
           ++ret;
-          std::cerr << "Error: Output->input language mismatch in the edge '" <<
-            N1.ToolPtr->Name() << "' -> '" << N2.ToolPtr->Name() << "'!\n";
-
-          std::cerr << "Expected one of { ";
+          errs() << "Error: Output->input language mismatch in the edge '"
+                 << N1.ToolPtr->Name() << "' -> '" << N2.ToolPtr->Name()
+                 << "'!\n"
+                 << "Expected one of { ";
 
           InLangs = N2.ToolPtr->InputLanguages();
           for (;*InLangs; ++InLangs) {
-            std::cerr << '\'' << *InLangs << (*(InLangs+1) ? "', " : "'");
+            errs() << '\'' << *InLangs << (*(InLangs+1) ? "', " : "'");
           }
 
-          std::cerr << " }, but got '" << OutLang << "'!\n\n";
+          errs() << " }, but got '" << OutLang << "'!\n\n";
         }
 
       }
@@ -406,9 +406,8 @@
       }
       else if (EdgeWeight == MaxWeight) {
         ++ret;
-        std::cerr
-          << "Error: there are multiple maximal edges stemming from the '"
-          << N.ToolPtr->Name() << "' node!\n\n";
+        errs() << "Error: there are multiple maximal edges stemming from the '"
+               << N.ToolPtr->Name() << "' node!\n\n";
         break;
       }
     }
@@ -440,9 +439,9 @@
   }
 
   if (deleted != NodesMap.size()) {
-    std::cerr << "Error: there are cycles in the compilation graph!\n"
-              << "Try inspecting the diagram produced by "
-      "'llvmc --view-graph'.\n\n";
+    errs() << "Error: there are cycles in the compilation graph!\n"
+           << "Try inspecting the diagram produced by "
+           << "'llvmc --view-graph'.\n\n";
     return 1;
   }
 
@@ -518,9 +517,9 @@
   std::ofstream O(OutputFilename.c_str());
 
   if (O.good()) {
-    std::cerr << "Writing '"<< OutputFilename << "' file...";
+    errs() << "Writing '"<< OutputFilename << "' file...";
     llvm::WriteGraph(O, this);
-    std::cerr << "done.\n";
+    errs() << "done.\n";
     O.close();
   }
   else {

Modified: llvm/trunk/lib/CompilerDriver/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=74507&r1=74506&r2=74507&view=diff

==============================================================================
--- llvm/trunk/lib/CompilerDriver/Main.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/Main.cpp Mon Jun 29 23:07:12 2009
@@ -16,9 +16,9 @@
 #include "llvm/CompilerDriver/Error.h"
 #include "llvm/CompilerDriver/Plugin.h"
 
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Path.h"
 
-#include <iostream>
 #include <stdexcept>
 #include <string>
 
@@ -91,7 +91,7 @@
     if (CheckGraph) {
       int ret = graph.Check();
       if (!ret)
-        std::cerr << "check-graph: no errors found.\n";
+        llvm::errs() << "check-graph: no errors found.\n";
 
       return ret;
     }
@@ -119,10 +119,10 @@
     return ec.code();
   }
   catch(const std::exception& ex) {
-    std::cerr << argv[0] << ": " << ex.what() << '\n';
+    llvm::errs() << argv[0] << ": " << ex.what() << '\n';
   }
   catch(...) {
-    std::cerr << argv[0] << ": unknown error!\n";
+    llvm::errs() << argv[0] << ": unknown error!\n";
   }
   return 1;
 }





More information about the llvm-commits mailing list