This is used by https://reviews.llvm.org/D86905 to support bitcode writer's incremental flush.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Other than a small style nit this LGTM
llvm/lib/Support/raw_ostream.cpp | ||
---|---|---|
919 | nit: the llvm style guide says no braces around single-line statements. Same in raw_fd_stream::read below. |
llvm/lib/Support/raw_ostream.cpp | ||
---|---|---|
919 | Thanks. Just learned that stdout is seekable if it is redirected to a normal file. |
llvm/include/llvm/Support/raw_ostream.h | ||
---|---|---|
591–592 | This comment doesn't seem to line up with the interface, where it talks about setting EC on failure. I'm guessing this isn't the EC from the constructor, since there's no state involved, and theres' no other EC parameter! | |
llvm/unittests/Support/raw_fd_stream_test.cpp | ||
2 | A couple of other test cases I'd like to see, depending on how practical it is (I suspect it's not practical, and if so, don't worry).
| |
39 | Is this environment variable ever going to be set? I'm not sure what the purpose of the extra logic is... | |
44 | I'm not sure I understand the need for the macro. Can this not just be the following? ASSERT_FALSE(sys::fs::createTemporaryFile("foo", "bar", FD, PATH)); (with optional explicit operator bool call, if needed) | |
48 | ec -> EC for LLVM style. | |
78 | Ditto ec -> EC here too. |
llvm/include/llvm/Support/raw_ostream.h | ||
---|---|---|
591–592 | Updated comments. | |
llvm/unittests/Support/raw_fd_stream_test.cpp | ||
2 | Looked into gmock a bit. To mock supportsSeeking, the code under test needs to rewrite to use either virtual method or templete: https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#MockingNonVirtualMethods Another way to test it is like this. At raw_fd_ostream::raw_fd_ostream, at a place where SupportsSeeking is set, we do if GlobalMockValue is set: SupportsSeeking = GlobalMockValue else SupportsSeeking = ... Here GlobalMockValue could be a global pointer. And the unit test can set it. EC can be tested in the same way. But this also needs to change the code under test. Did any other LLVM test code do something similar? | |
39 | This code refers to the test raw_pwrite_ostreamTest from llvm/unittests/Support/raw_pwrite_stream_test.cpp That test has a death test at the end. This new test does not have death test. I removed unrelated code. |
LGTM.
llvm/unittests/Support/raw_fd_stream_test.cpp | ||
---|---|---|
2 | Yeah, I didn't think this through hard enough, and I don't see a great way of doing this in the tests (I don't think rewriting the code for greater testability is necessary). If you can manually locally verify that the code works as desired, then that would be sufficient for my comment. |
Looks great!
llvm/include/llvm/Support/raw_ostream.h | ||
---|---|---|
55 | OK_LastFDStream is not used and should be deleted |
OK_LastFDStream is not used and should be deleted