[llvm-commits] CVS: llvm/include/llvm/Support/Casting.h Debug.h GraphWriter.h PassNameParser.h

Bill Wendling isanbard at gmail.com
Fri Nov 17 01:53:03 PST 2006



Changes in directory llvm/include/llvm/Support:

Casting.h updated: 1.15 -> 1.16
Debug.h updated: 1.10 -> 1.11
GraphWriter.h updated: 1.30 -> 1.31
PassNameParser.h updated: 1.12 -> 1.13
---
Log message:

Used llvm_ostream instead of std::ostream objects. This will reduce use
of the icky <iostream> class.


---
Diffs of the changes:  (+13 -31)

 Casting.h        |    6 +++---
 Debug.h          |   20 +-------------------
 GraphWriter.h    |   14 +++++++-------
 PassNameParser.h |    4 ++--
 4 files changed, 13 insertions(+), 31 deletions(-)


Index: llvm/include/llvm/Support/Casting.h
diff -u llvm/include/llvm/Support/Casting.h:1.15 llvm/include/llvm/Support/Casting.h:1.16
--- llvm/include/llvm/Support/Casting.h:1.15	Sat May 13 12:50:38 2006
+++ llvm/include/llvm/Support/Casting.h	Fri Nov 17 03:52:49 2006
@@ -235,7 +235,7 @@
 
 
 #ifdef DEBUG_CAST_OPERATORS
-#include <iostream>
+#include "llvm/Support/Debug.h"
 
 struct bar {
   bar() {}
@@ -245,13 +245,13 @@
 struct foo {
   void ext() const;
   /*  static bool classof(const bar *X) {
-    cerr << "Classof: " << X << "\n";
+    llvm_cerr << "Classof: " << X << "\n";
     return true;
     }*/
 };
 
 template <> inline bool isa_impl<foo,bar>(const bar &Val) {
-  cerr << "Classof: " << &Val << "\n";
+  llvm_cerr << "Classof: " << &Val << "\n";
   return true;
 }
 


Index: llvm/include/llvm/Support/Debug.h
diff -u llvm/include/llvm/Support/Debug.h:1.10 llvm/include/llvm/Support/Debug.h:1.11
--- llvm/include/llvm/Support/Debug.h:1.10	Thu Nov 16 19:43:48 2006
+++ llvm/include/llvm/Support/Debug.h	Fri Nov 17 03:52:49 2006
@@ -26,7 +26,7 @@
 #ifndef LLVM_SUPPORT_DEBUG_H
 #define LLVM_SUPPORT_DEBUG_H
 
-#include <ostream>              // Doesn't have static d'tors!!
+#include "llvm/Support/Streams.h"
 
 namespace llvm {
 
@@ -61,24 +61,6 @@
   do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0)
 #endif
 
-/// llvm_ostream - Acts like an ostream. However, it doesn't print things out if
-/// an ostream isn't specified.
-/// 
-class llvm_ostream {
-  std::ostream* Stream;
-public:
-  llvm_ostream() : Stream(0) {}
-  llvm_ostream(std::ostream& OStream) : Stream(&OStream) {}
-
-  template <typename Ty>
-  llvm_ostream& operator << (const Ty& Thing) {
-#ifndef NDEBUG
-    if (Stream) *Stream << Thing;
-#endif
-    return *this;
-  }
-};
-
 /// getErrorOutputStream - Returns the error output stream (std::cerr). This
 /// places the std::c* I/O streams into one .cpp file and relieves the whole
 /// program from having to have hundreds of static c'tor/d'tors for them.


Index: llvm/include/llvm/Support/GraphWriter.h
diff -u llvm/include/llvm/Support/GraphWriter.h:1.30 llvm/include/llvm/Support/GraphWriter.h:1.31
--- llvm/include/llvm/Support/GraphWriter.h:1.30	Mon Oct  2 07:26:53 2006
+++ llvm/include/llvm/Support/GraphWriter.h	Fri Nov 17 03:52:49 2006
@@ -23,12 +23,12 @@
 #ifndef LLVM_SUPPORT_GRAPHWRITER_H
 #define LLVM_SUPPORT_GRAPHWRITER_H
 
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/DOTGraphTraits.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/System/Path.h"
-#include <vector>
-#include <iostream>
 #include <fstream>
+#include <vector>
 
 namespace llvm {
 
@@ -247,16 +247,16 @@
   std::string ErrMsg;
   sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
   if (Filename.isEmpty()) {
-    std::cerr << "Error: " << ErrMsg << "\n";
+    llvm_cerr << "Error: " << ErrMsg << "\n";
     return Filename;
   }
   Filename.appendComponent(Name + ".dot");
   if (Filename.makeUnique(true,&ErrMsg)) {
-    std::cerr << "Error: " << ErrMsg << "\n";
+    llvm_cerr << "Error: " << ErrMsg << "\n";
     return sys::Path();
   }
 
-  std::cerr << "Writing '" << Filename << "'... ";
+  llvm_cerr << "Writing '" << Filename << "'... ";
   
   std::ofstream O(Filename.c_str());
 
@@ -275,12 +275,12 @@
 
     // Output the end of the graph
     W.writeFooter();
-    std::cerr << " done. \n";
+    llvm_cerr << " done. \n";
 
     O.close();
     
   } else {
-    std::cerr << "error opening file for writing!\n";
+    llvm_cerr << "error opening file for writing!\n";
     Filename.clear();
   }
   


Index: llvm/include/llvm/Support/PassNameParser.h
diff -u llvm/include/llvm/Support/PassNameParser.h:1.12 llvm/include/llvm/Support/PassNameParser.h:1.13
--- llvm/include/llvm/Support/PassNameParser.h:1.12	Sun Aug 27 17:11:07 2006
+++ llvm/include/llvm/Support/PassNameParser.h	Fri Nov 17 03:52:49 2006
@@ -24,9 +24,9 @@
 #define LLVM_SUPPORT_PASS_NAME_PARSER_H
 
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Pass.h"
 #include <algorithm>
-#include <iostream>
 
 namespace llvm {
 
@@ -66,7 +66,7 @@
   virtual void passRegistered(const PassInfo *P) {
     if (ignorablePass(P) || !Opt) return;
     if (findOption(P->getPassArgument()) != getNumOptions()) {
-      std::cerr << "Two passes with the same argument (-"
+      llvm_cerr << "Two passes with the same argument (-"
                 << P->getPassArgument() << ") attempted to be registered!\n";
       abort();
     }






More information about the llvm-commits mailing list