[all-commits] [llvm/llvm-project] e18ea6: Support: Skip buffering buffer_unique_ostream's ow...
Duncan P. N. Exon Smith via All-commits
all-commits at lists.llvm.org
Fri Oct 22 16:26:08 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e18ea6f2946a10042258b976e60166a926ee939a
https://github.com/llvm/llvm-project/commit/e18ea6f2946a10042258b976e60166a926ee939a
Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
Date: 2021-10-22 (Fri, 22 Oct 2021)
Changed paths:
M llvm/include/llvm/Support/raw_ostream.h
M llvm/unittests/Support/CMakeLists.txt
A llvm/unittests/Support/buffer_ostream_test.cpp
Log Message:
-----------
Support: Skip buffering buffer_unique_ostream's owned stream
Change buffer_unique_ostream's constructor to call
raw_ostream::SetUnbuffered() on its owned stream. Otherwise,
buffer_unique_ostream's destructor could cause the owned stream to
temporarily allocate a buffer only to be immediately flushed.
Also add some tests for buffer_ostream and buffer_unique_ostream. Use
the same naming scheme as other raw_ostream-related tests (e.g.,
`raw_ostreamTest` for the fixture, `raw_ostream_test.cpp` for the
filename).
(I considered changing buffer_ostream in the same way (calling
SetUnbuffered on the referenced stream), but that seemed like overreach
since the client may have more things to write.)
(I considered merging buffer_ostream and buffer_unique_ostream into a
single class (with a `raw_ostream&` and a `std::unique_ptr` that is only
sometimes used), but that makes the class bigger and the small amount of
code deduplication seems uncompelling.)
Differential Revision: https://reviews.llvm.org/D110369
More information about the All-commits
mailing list