Add raw_null_ostream and llvm::nulls(), a raw_ostream that discards output.
- No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76103 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 397d296..3cec18b 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -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;
+}