Remove more iostream header includes. Needed to implement a "FlushStream"
authorBill Wendling <isanbard@gmail.com>
Thu, 29 May 2008 21:46:33 +0000 (21:46 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 29 May 2008 21:46:33 +0000 (21:46 +0000)
function to flush a specified std::ostream.

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

include/llvm/Support/Streams.h
lib/Support/Streams.cpp
lib/System/Unix/Program.inc
lib/Target/CellSPU/SPUISelDAGToDAG.cpp
lib/Target/CellSPU/SPUInstrInfo.cpp
lib/Target/CellSPU/SPURegisterInfo.cpp

index 46bac8baaf6b613c6a9be5bcf01e97180b59cdc5..2444d5b6af35f28d8f6f153973531c508cccb5c4 100644 (file)
@@ -19,6 +19,9 @@
 
 namespace llvm {
 
+  /// FlushStream - Function called by BaseStream to flush an ostream.
+  void FlushStream(std::ostream &S);
+
   /// BaseStream - Acts like the STL streams. It's a wrapper for the std::cerr,
   /// std::cout, std::cin, etc. streams. However, it doesn't require #including
   /// @verbatim <iostream> @endverbatm in every file (doing so increases static 
@@ -39,6 +42,11 @@ namespace llvm {
       return *this;
     }
 
+    void flush() {
+      if (Stream)
+        FlushStream(*Stream);
+    }
+
     template <typename Ty>
     BaseStream &operator << (const Ty &Thing) {
       if (Stream) *Stream << Thing;
index 122955ff4eb7ffd97a54a3deda0500dc8d86e3bc..cf6cfeb7fd0443c6c896efce694957e588f9cd90 100644 (file)
@@ -19,3 +19,12 @@ using namespace llvm;
 OStream llvm::cout(std::cout);
 OStream llvm::cerr(std::cerr);
 IStream llvm::cin(std::cin);
+
+namespace llvm {
+
+/// FlushStream - Function called by BaseStream to flush an ostream.
+void FlushStream(std::ostream &S) {
+  S << std::flush;
+}
+
+} // end anonymous namespace
index d0dade1f8cadc2467e5c0c988a388d4a82f509cf..182e14db096f00265696b1a28ced48679e6dd0ee 100644 (file)
@@ -17,8 +17,8 @@
 //===----------------------------------------------------------------------===//
 
 #include <llvm/Config/config.h>
+#include <llvm/Support/Streams.h>
 #include "Unix.h"
-#include <iostream>
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
@@ -210,8 +210,8 @@ Program::ExecuteAndWait(const Path& path,
   }
 
   // Make sure stderr and stdout have been flushed
-  std::cerr << std::flush;
-  std::cout << std::flush;
+  cerr.flush();
+  cout.flush();
   fsync(1);
   fsync(2);
 
index c6628aca63a9a59c13e9e3f85dbfe3a0d5cd7e4f..b491b13b71b655dc4a7a563d486d189e2c985ca9 100644 (file)
@@ -31,7 +31,6 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Compiler.h"
-#include <iostream>
 #include <queue>
 #include <set>
 
index bf94cdc0946e4bdfffe8f66ea9abf8a63498550f..3e991a9e79c9cc3f9344aeb6e490062af6320a37 100644 (file)
@@ -17,7 +17,7 @@
 #include "SPUTargetMachine.h"
 #include "SPUGenInstrInfo.inc"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
-#include <iostream>
+#include "llvm/Support/Streams.h"
 
 using namespace llvm;
 
@@ -218,7 +218,7 @@ void SPUInstrInfo::copyRegToReg(MachineBasicBlock &MBB,
     BuildMI(MBB, MI, get(SPU::ORv4i32), DestReg).addReg(SrcReg)
       .addReg(SrcReg);
   } else {
-    std::cerr << "Attempt to copy unknown/unsupported register class!\n";
+    cerr << "Attempt to copy unknown/unsupported register class!\n";
     abort();
   }
 }
index ea69d215a538e0345e1ddfb42d89a54e1c569fde..b6b7fd3174159be0d69100e0319e1f6d5eb3f0f7 100644 (file)
@@ -40,7 +40,6 @@
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include <cstdlib>
-#include <iostream>
 
 using namespace llvm;
 
@@ -178,7 +177,7 @@ unsigned SPURegisterInfo::getRegisterNumbering(unsigned RegEnum) {
   case SPU::R126: return 126;
   case SPU::R127: return 127;
   default:
-    std::cerr << "Unhandled reg in SPURegisterInfo::getRegisterNumbering!\n";
+    cerr << "Unhandled reg in SPURegisterInfo::getRegisterNumbering!\n";
     abort();
   }
 }