[llvm-commits] [llvm] r81912 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp unittests/Support/raw_ostream_test.cpp
Daniel Dunbar
daniel at zuster.org
Tue Sep 15 13:31:46 PDT 2009
Author: ddunbar
Date: Tue Sep 15 15:31:46 2009
New Revision: 81912
URL: http://llvm.org/viewvc/llvm-project?rev=81912&view=rev
Log:
Drop the raw_ostream required buffer size to 1.
- As best I can tell, we have eliminated all the code which used to require a
larger buffer size.
Modified:
llvm/trunk/include/llvm/Support/raw_ostream.h
llvm/trunk/lib/Support/raw_ostream.cpp
llvm/trunk/unittests/Support/raw_ostream_test.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=81912&r1=81911&r2=81912&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Tue Sep 15 15:31:46 2009
@@ -41,7 +41,7 @@
/// 1. Unbuffered (BufferMode == Unbuffered)
/// 1. Uninitialized (BufferMode != Unbuffered && OutBufStart == 0).
/// 2. Buffered (BufferMode != Unbuffered && OutBufStart != 0 &&
- /// OutBufEnd - OutBufStart >= 64).
+ /// OutBufEnd - OutBufStart >= 1).
///
/// If buffered, then the raw_ostream owns the buffer if (BufferMode ==
/// InternalBuffer); otherwise the buffer has been set via SetBuffer and is
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=81912&r1=81911&r2=81912&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Tue Sep 15 15:31:46 2009
@@ -84,8 +84,8 @@
void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
BufferKind Mode) {
assert(((Mode == Unbuffered && BufferStart == 0 && Size == 0) ||
- (Mode != Unbuffered && BufferStart && Size >= 64)) &&
- "stream must be unbuffered, or have >= 64 bytes of buffer");
+ (Mode != Unbuffered && BufferStart && Size)) &&
+ "stream must be unbuffered or have at least one byte");
// Make sure the current buffer is free of content (we can't flush here; the
// child buffer management logic will be in write_impl).
assert(GetNumBytesInBuffer() == 0 && "Current buffer is non-empty!");
Modified: llvm/trunk/unittests/Support/raw_ostream_test.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/raw_ostream_test.cpp?rev=81912&r1=81911&r2=81912&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/raw_ostream_test.cpp (original)
+++ llvm/trunk/unittests/Support/raw_ostream_test.cpp Tue Sep 15 15:31:46 2009
@@ -117,4 +117,14 @@
EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 10));
}
+TEST(raw_ostreamTest, TinyBuffer) {
+ std::string Str;
+ raw_string_ostream OS(Str);
+ OS.SetBufferSize(1);
+ OS << "hello";
+ OS << 1;
+ OS << 'w' << 'o' << 'r' << 'l' << 'd';
+ EXPECT_EQ("hello1world", OS.str());
+}
+
}
More information about the llvm-commits
mailing list