[PATCH] D86913: Add raw_fd_stream that supports reading/seeking/writing

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 12:17:03 PDT 2020


MaskRay added inline comments.


================
Comment at: llvm/lib/Support/raw_ostream.cpp:920
+  // Do not support STDOUT_FILENO and non-seekable files.
+  if (Filename == "-" || !supportsSeeking()) {
+    EC = std::make_error_code(std::errc::invalid_argument);
----------------
JDevlieghere wrote:
> nit: the llvm style guide says no braces around single-line statements. Same in `raw_fd_stream::read` below. 
If stdout happens to be seekable, can the `Filename == "-" ` restriction be lifted?


================
Comment at: llvm/lib/Support/raw_ostream.cpp:927
+  assert(get_fd() >= 0 && "File already closed.");
+  ssize_t RET = ::read(get_fd(), (void *)Ptr, Size);
+  if (RET >= 0) {
----------------
Ret


================
Comment at: llvm/lib/Support/raw_ostream.cpp:928
+  ssize_t RET = ::read(get_fd(), (void *)Ptr, Size);
+  if (RET >= 0) {
+    inc_pos(RET);
----------------
no braces


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86913/new/

https://reviews.llvm.org/D86913



More information about the llvm-commits mailing list