[llvm-commits] [llvm] r76103 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp
Daniel Dunbar
daniel at zuster.org
Thu Jul 16 14:17:55 PDT 2009
Author: ddunbar
Date: Thu Jul 16 16:17:53 2009
New Revision: 76103
URL: http://llvm.org/viewvc/llvm-project?rev=76103&view=rev
Log:
Add raw_null_ostream and llvm::nulls(), a raw_ostream that discards output.
- No functionality change.
Modified:
llvm/trunk/include/llvm/Support/raw_ostream.h
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=76103&r1=76102&r2=76103&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Thu Jul 16 16:17:53 2009
@@ -327,6 +327,9 @@
/// Use it like: errs() << "foo" << "bar";
raw_ostream &errs();
+/// nulls() - This returns a reference to a raw_ostream which simply discards
+/// output.
+raw_ostream &nulls();
//===----------------------------------------------------------------------===//
// Output Stream Adaptors
@@ -399,6 +402,19 @@
uint64_t tell();
};
+/// raw_null_ostream - A raw_ostream that discards all output.
+class raw_null_ostream : public raw_ostream {
+ /// write_impl - See raw_ostream::write_impl.
+ virtual void write_impl(const char *Ptr, size_t size);
+
+ /// current_pos - Return the current position within the stream, not
+ /// counting the bytes currently in the buffer.
+ virtual uint64_t current_pos();
+
+public:
+ explicit raw_null_ostream() {}
+};
+
} // end llvm namespace
#endif
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=76103&r1=76102&r2=76103&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Thu Jul 16 16:17:53 2009
@@ -375,6 +375,12 @@
return S;
}
+/// nulls() - This returns a reference to a raw_ostream which discards output.
+raw_ostream &llvm::nulls() {
+ static raw_null_ostream S;
+ return S;
+}
+
//===----------------------------------------------------------------------===//
// raw_os_ostream
//===----------------------------------------------------------------------===//
@@ -422,3 +428,14 @@
uint64_t raw_svector_ostream::tell() {
return OS.size() + GetNumBytesInBuffer();
}
+
+//===----------------------------------------------------------------------===//
+// raw_null_ostream
+//===----------------------------------------------------------------------===//
+
+void raw_null_ostream::write_impl(const char *Ptr, size_t Size) {
+}
+
+uint64_t raw_null_ostream::current_pos() {
+ return 0;
+}
More information about the llvm-commits
mailing list