[llvm-commits] CVS: llvm/include/llvm/Support/Casting.h ConstantRange.h Debug.h GraphWriter.h PassNameParser.h Streams.h
Bill Wendling
isanbard at gmail.com
Wed Dec 6 17:32:01 PST 2006
Changes in directory llvm/include/llvm/Support:
Casting.h updated: 1.16 -> 1.17
ConstantRange.h updated: 1.10 -> 1.11
Debug.h updated: 1.11 -> 1.12
GraphWriter.h updated: 1.31 -> 1.32
PassNameParser.h updated: 1.15 -> 1.16
Streams.h updated: 1.4 -> 1.5
---
Log message:
Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.
---
Diffs of the changes: (+47 -31)
Casting.h | 4 ++--
ConstantRange.h | 2 +-
Debug.h | 4 ++--
GraphWriter.h | 10 +++++-----
PassNameParser.h | 4 ++--
Streams.h | 54 +++++++++++++++++++++++++++++++++++-------------------
6 files changed, 47 insertions(+), 31 deletions(-)
Index: llvm/include/llvm/Support/Casting.h
diff -u llvm/include/llvm/Support/Casting.h:1.16 llvm/include/llvm/Support/Casting.h:1.17
--- llvm/include/llvm/Support/Casting.h:1.16 Fri Nov 17 03:52:49 2006
+++ llvm/include/llvm/Support/Casting.h Wed Dec 6 19:30:31 2006
@@ -245,13 +245,13 @@
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;
}
Index: llvm/include/llvm/Support/ConstantRange.h
diff -u llvm/include/llvm/Support/ConstantRange.h:1.10 llvm/include/llvm/Support/ConstantRange.h:1.11
--- llvm/include/llvm/Support/ConstantRange.h:1.10 Tue Nov 28 16:21:29 2006
+++ llvm/include/llvm/Support/ConstantRange.h Wed Dec 6 19:30:31 2006
@@ -141,7 +141,7 @@
/// 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;
Index: llvm/include/llvm/Support/Debug.h
diff -u llvm/include/llvm/Support/Debug.h:1.11 llvm/include/llvm/Support/Debug.h:1.12
--- llvm/include/llvm/Support/Debug.h:1.11 Fri Nov 17 03:52:49 2006
+++ llvm/include/llvm/Support/Debug.h Wed Dec 6 19:30:31 2006
@@ -65,10 +65,10 @@
/// 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
Index: llvm/include/llvm/Support/GraphWriter.h
diff -u llvm/include/llvm/Support/GraphWriter.h:1.31 llvm/include/llvm/Support/GraphWriter.h:1.32
--- llvm/include/llvm/Support/GraphWriter.h:1.31 Fri Nov 17 03:52:49 2006
+++ llvm/include/llvm/Support/GraphWriter.h Wed Dec 6 19:30:31 2006
@@ -247,16 +247,16 @@
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 @@
// 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();
}
Index: llvm/include/llvm/Support/PassNameParser.h
diff -u llvm/include/llvm/Support/PassNameParser.h:1.15 llvm/include/llvm/Support/PassNameParser.h:1.16
--- llvm/include/llvm/Support/PassNameParser.h:1.15 Fri Dec 1 17:27:45 2006
+++ llvm/include/llvm/Support/PassNameParser.h Wed Dec 6 19:30:31 2006
@@ -65,8 +65,8 @@
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());
Index: llvm/include/llvm/Support/Streams.h
diff -u llvm/include/llvm/Support/Streams.h:1.4 llvm/include/llvm/Support/Streams.h:1.5
--- llvm/include/llvm/Support/Streams.h:1.4 Tue Nov 28 18:19:40 2006
+++ llvm/include/llvm/Support/Streams.h Wed Dec 6 19:30:31 2006
@@ -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
More information about the llvm-commits
mailing list