]> granicus.if.org Git - llvm/commit
Don't allow pwrite to resize a stream.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Apr 2015 13:04:30 +0000 (13:04 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 20 Apr 2015 13:04:30 +0000 (13:04 +0000)
commitf30ac8f5ece0c90d804cd6ddec142ac05e1d32f1
treebbf149f5636e385bf52a628e10fde4dfeaeea998
parentdbef0175c327c9b0987587402f12ba5845da381a
Don't allow pwrite to resize a stream.

The current implementations could exhibit some behavior differences:

raw_fd_ostream: Whatever the underlying fd does with seek+write. In a normal
file, the write position would be back to the old offset.

raw_svector_ostream: The write position is always the end of the stream, so
after pwrite the write position would be the new end. This matches what OS_X
(all BSD?) do with a pwrite in a O_APPEND fd.

Given that we don't need that feature and don't use O_APPEND a lot in LLVM,
just disallow it.

I am open to suggestions on renaming pwrite to something else, but this fixes
the issue for now.

Thanks to Yaron Keren for reporting it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235303 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/raw_ostream.h
lib/Support/raw_ostream.cpp
unittests/Support/raw_pwrite_stream_test.cpp