Remove more iostream header includes. Needed to implement a "FlushStream"

function to flush a specified std::ostream.

llvm-svn: 51705
This commit is contained in:
Bill Wendling 2008-05-29 21:46:33 +00:00
parent bf5b228c32
commit 33e396d041
6 changed files with 23 additions and 8 deletions

View File

@ -19,6 +19,9 @@
namespace llvm { 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, /// 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 /// std::cout, std::cin, etc. streams. However, it doesn't require #including
/// @verbatim <iostream> @endverbatm in every file (doing so increases static /// @verbatim <iostream> @endverbatm in every file (doing so increases static
@ -39,6 +42,11 @@ namespace llvm {
return *this; return *this;
} }
void flush() {
if (Stream)
FlushStream(*Stream);
}
template <typename Ty> template <typename Ty>
BaseStream &operator << (const Ty &Thing) { BaseStream &operator << (const Ty &Thing) {
if (Stream) *Stream << Thing; if (Stream) *Stream << Thing;

View File

@ -19,3 +19,12 @@ using namespace llvm;
OStream llvm::cout(std::cout); OStream llvm::cout(std::cout);
OStream llvm::cerr(std::cerr); OStream llvm::cerr(std::cerr);
IStream llvm::cin(std::cin); 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

View File

@ -17,8 +17,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include <llvm/Config/config.h> #include <llvm/Config/config.h>
#include <llvm/Support/Streams.h>
#include "Unix.h" #include "Unix.h"
#include <iostream>
#if HAVE_SYS_STAT_H #if HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
@ -210,8 +210,8 @@ Program::ExecuteAndWait(const Path& path,
} }
// Make sure stderr and stdout have been flushed // Make sure stderr and stdout have been flushed
std::cerr << std::flush; cerr.flush();
std::cout << std::flush; cout.flush();
fsync(1); fsync(1);
fsync(2); fsync(2);

View File

@ -31,7 +31,6 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include <iostream>
#include <queue> #include <queue>
#include <set> #include <set>

View File

@ -17,7 +17,7 @@
#include "SPUTargetMachine.h" #include "SPUTargetMachine.h"
#include "SPUGenInstrInfo.inc" #include "SPUGenInstrInfo.inc"
#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineInstrBuilder.h"
#include <iostream> #include "llvm/Support/Streams.h"
using namespace llvm; using namespace llvm;
@ -218,7 +218,7 @@ void SPUInstrInfo::copyRegToReg(MachineBasicBlock &MBB,
BuildMI(MBB, MI, get(SPU::ORv4i32), DestReg).addReg(SrcReg) BuildMI(MBB, MI, get(SPU::ORv4i32), DestReg).addReg(SrcReg)
.addReg(SrcReg); .addReg(SrcReg);
} else { } else {
std::cerr << "Attempt to copy unknown/unsupported register class!\n"; cerr << "Attempt to copy unknown/unsupported register class!\n";
abort(); abort();
} }
} }

View File

@ -40,7 +40,6 @@
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include <cstdlib> #include <cstdlib>
#include <iostream>
using namespace llvm; using namespace llvm;
@ -178,7 +177,7 @@ unsigned SPURegisterInfo::getRegisterNumbering(unsigned RegEnum) {
case SPU::R126: return 126; case SPU::R126: return 126;
case SPU::R127: return 127; case SPU::R127: return 127;
default: default:
std::cerr << "Unhandled reg in SPURegisterInfo::getRegisterNumbering!\n"; cerr << "Unhandled reg in SPURegisterInfo::getRegisterNumbering!\n";
abort(); abort();
} }
} }