llvm.org GIT mirror llvm / c8213b7
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81912 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 10 years ago
3 changed file(s) with 13 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4040 /// 1. Unbuffered (BufferMode == Unbuffered)
4141 /// 1. Uninitialized (BufferMode != Unbuffered && OutBufStart == 0).
4242 /// 2. Buffered (BufferMode != Unbuffered && OutBufStart != 0 &&
43 /// OutBufEnd - OutBufStart >= 64).
43 /// OutBufEnd - OutBufStart >= 1).
4444 ///
4545 /// If buffered, then the raw_ostream owns the buffer if (BufferMode ==
4646 /// InternalBuffer); otherwise the buffer has been set via SetBuffer and is
8383 void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
8484 BufferKind Mode) {
8585 assert(((Mode == Unbuffered && BufferStart == 0 && Size == 0) ||
86 (Mode != Unbuffered && BufferStart && Size >= 64)) &&
87 "stream must be unbuffered, or have >= 64 bytes of buffer");
86 (Mode != Unbuffered && BufferStart && Size)) &&
87 "stream must be unbuffered or have at least one byte");
8888 // Make sure the current buffer is free of content (we can't flush here; the
8989 // child buffer management logic will be in write_impl).
9090 assert(GetNumBytesInBuffer() == 0 && "Current buffer is non-empty!");
116116 EXPECT_EQ("1.20", printToString(format("%.2f", 1.2), 10));
117117 }
118118
119 TEST(raw_ostreamTest, TinyBuffer) {
120 std::string Str;
121 raw_string_ostream OS(Str);
122 OS.SetBufferSize(1);
123 OS << "hello";
124 OS << 1;
125 OS << 'w' << 'o' << 'r' << 'l' << 'd';
126 EXPECT_EQ("hello1world", OS.str());
119127 }
128
129 }