summaryrefslogtreecommitdiff
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2006-12-07 01:30:32 +0000
committerBill Wendling <isanbard@gmail.com>2006-12-07 01:30:32 +0000
commite81561909d128c6e2d8033cb5465a49b2596b26a (patch)
tree6f2845604d482bc86d8d12aae500292c561d8cd7 /include/llvm/Support
parent85c671b90870705ba7e10baf99aa306c843f1325 (diff)
downloadllvm-e81561909d128c6e2d8033cb5465a49b2596b26a.tar.gz
llvm-e81561909d128c6e2d8033cb5465a49b2596b26a.tar.bz2
llvm-e81561909d128c6e2d8033cb5465a49b2596b26a.tar.xz
Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32298 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/Casting.h4
-rw-r--r--include/llvm/Support/ConstantRange.h2
-rw-r--r--include/llvm/Support/Debug.h4
-rw-r--r--include/llvm/Support/GraphWriter.h10
-rw-r--r--include/llvm/Support/PassNameParser.h4
-rw-r--r--include/llvm/Support/Streams.h54
6 files changed, 47 insertions, 31 deletions
diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h
index fff44f6e64..dc318395cc 100644
--- a/include/llvm/Support/Casting.h
+++ b/include/llvm/Support/Casting.h
@@ -245,13 +245,13 @@ private:
struct foo {
void ext() const;
/* static bool classof(const bar *X) {
- llvm_cerr << "Classof: " << X << "\n";
+ cerr << "Classof: " << X << "\n";
return true;
}*/
};
template <> inline bool isa_impl<foo,bar>(const bar &Val) {
- llvm_cerr << "Classof: " << &Val << "\n";
+ cerr << "Classof: " << &Val << "\n";
return true;
}
diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h
index 90a29902c3..6866ffeb11 100644
--- a/include/llvm/Support/ConstantRange.h
+++ b/include/llvm/Support/ConstantRange.h
@@ -141,7 +141,7 @@ class ConstantRange {
/// print - Print out the bounds to a stream...
///
- void print(llvm_ostream &OS) const {
+ void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream());
}
void print(std::ostream &OS) const;
diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h
index 9f0f1611d7..09878b9d1e 100644
--- a/include/llvm/Support/Debug.h
+++ b/include/llvm/Support/Debug.h
@@ -65,10 +65,10 @@ bool isCurrentDebugType(const char *Type);
/// 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.
///
-llvm_ostream getErrorOutputStream(const char *DebugType);
+OStream getErrorOutputStream(const char *DebugType);
#ifdef NDEBUG
-#define DOUT llvm_ostream()
+#define DOUT NullStream
#else
#define DOUT getErrorOutputStream(DEBUG_TYPE)
#endif
diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h
index 8602e74c14..b9566b84f8 100644
--- a/include/llvm/Support/GraphWriter.h
+++ b/include/llvm/Support/GraphWriter.h
@@ -247,16 +247,16 @@ sys::Path WriteGraph(const GraphType &G,
std::string ErrMsg;
sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
if (Filename.isEmpty()) {
- llvm_cerr << "Error: " << ErrMsg << "\n";
+ cerr << "Error: " << ErrMsg << "\n";
return Filename;
}
Filename.appendComponent(Name + ".dot");
if (Filename.makeUnique(true,&ErrMsg)) {
- llvm_cerr << "Error: " << ErrMsg << "\n";
+ cerr << "Error: " << ErrMsg << "\n";
return sys::Path();
}
- llvm_cerr << "Writing '" << Filename << "'... ";
+ cerr << "Writing '" << Filename << "'... ";
std::ofstream O(Filename.c_str());
@@ -275,12 +275,12 @@ sys::Path WriteGraph(const GraphType &G,
// Output the end of the graph
W.writeFooter();
- llvm_cerr << " done. \n";
+ cerr << " done. \n";
O.close();
} else {
- llvm_cerr << "error opening file for writing!\n";
+ cerr << "error opening file for writing!\n";
Filename.clear();
}
diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h
index fef63c3032..83653aa745 100644
--- a/include/llvm/Support/PassNameParser.h
+++ b/include/llvm/Support/PassNameParser.h
@@ -65,8 +65,8 @@ public:
virtual void passRegistered(const PassInfo *P) {
if (ignorablePass(P) || !Opt) return;
if (findOption(P->getPassArgument()) != getNumOptions()) {
- llvm_cerr << "Two passes with the same argument (-"
- << P->getPassArgument() << ") attempted to be registered!\n";
+ cerr << "Two passes with the same argument (-"
+ << P->getPassArgument() << ") attempted to be registered!\n";
abort();
}
addLiteralOption(P->getPassArgument(), P, P->getPassName());
diff --git a/include/llvm/Support/Streams.h b/include/llvm/Support/Streams.h
index a422756c63..c4afc86baa 100644
--- a/include/llvm/Support/Streams.h
+++ b/include/llvm/Support/Streams.h
@@ -7,48 +7,64 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements a wrapper for the std::cout and std::cerr I/O streams.
-// It prevents the need to include <iostream> to each file just to get I/O.
+// This file implements a wrapper for the STL I/O streams. It prevents the need
+// to include <iostream> in a file just to get I/O.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_STREAMS_H
#define LLVM_SUPPORT_STREAMS_H
-#include <ostream> // Doesn't have static d'tors!!
+#include <sstream>
namespace llvm {
- /// llvm_ostream - Acts like an ostream. It's a wrapper for the std::cerr and
- /// std::cout ostreams. However, it doesn't require #including <iostream> in
- /// every file, which increases static c'tors & d'tors in the object code.
+ /// 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
+ /// <iostream> in every file (doing so increases static c'tors & d'tors in the
+ /// object code).
///
- class llvm_ostream {
- std::ostream* Stream;
+ template <typename StreamTy>
+ class BaseStream {
+ StreamTy *Stream;
public:
- llvm_ostream() : Stream(0) {}
- llvm_ostream(std::ostream &OStream) : Stream(&OStream) {}
+ BaseStream() : Stream(0) {}
+ BaseStream(StreamTy &S) : Stream(&S) {}
+ BaseStream(StreamTy *S) : Stream(S) {}
- std::ostream* stream() const { return Stream; }
+ StreamTy *stream() const { return Stream; }
- inline llvm_ostream &operator << (std::ostream& (*Func)(std::ostream&)) {
+ inline BaseStream &operator << (StreamTy &(*Func)(StreamTy&)) {
if (Stream) *Stream << Func;
return *this;
}
-
+
template <typename Ty>
- llvm_ostream &operator << (const Ty &Thing) {
+ BaseStream &operator << (const Ty &Thing) {
if (Stream) *Stream << Thing;
return *this;
}
- bool operator == (const std::ostream &OS) { return &OS == Stream; }
- bool operator == (const llvm_ostream &OS) { return OS.Stream == Stream; }
+ template <typename Ty>
+ BaseStream &operator >> (const Ty &Thing) {
+ if (Stream) *Stream >> Thing;
+ return *this;
+ }
+
+ bool operator == (const StreamTy &S) { return &S == Stream; }
+ bool operator != (const StreamTy &S) { return !(*this == S); }
+ bool operator == (const BaseStream &S) { return S.Stream == Stream; }
+ bool operator != (const BaseStream &S) { return !(*this == S); }
};
- extern llvm_ostream llvm_null;
- extern llvm_ostream llvm_cout;
- extern llvm_ostream llvm_cerr;
+ typedef BaseStream<std::ostream> OStream;
+ typedef BaseStream<std::istream> IStream;
+ typedef BaseStream<std::stringstream> StringStream;
+
+ extern OStream NullStream;
+ extern OStream cout;
+ extern OStream cerr;
+ extern IStream cin;
} // End llvm namespace