[llvm] r185832 - Create files with the correct permission instead of changing it afterwards.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Jul 12 21:30:10 PDT 2013


On 12 July 2013 22:16, Sean Silva <silvas at purdue.edu> wrote:
> The raw calls to open/close in this code (and the corresponding #ifdef's)
> make me sad. It seems like the whole reason that this code is using raw
> calls to open() and close() is because of
>
> 1. This call to sys::fs::setLastModificationAndAccessTime, which needs the
> FD. Would it be possible to add a getter to raw_fd_ostream for getting the
> FD? Then you could use tool_output_file.os().get_fd() instead of keeping the
> FD around explicitly.
>
> 2. Setting the mode. It seems like we could just add an extra argument
> (defaulted to 0644) to raw_fd_ostream's constructor, which can then just
> pass it in on the call
> <http://llvm.org/docs/doxygen/html/raw__ostream_8cpp_source.html#l00464>.
>
> Also can we use tool_output_file here (after adding a default parameter to
> the constructor that gets passed though to raw_fd_ostream's constructor)?
>
> Also, for the O_* constants above, you can use the corresponding F_* flags
> which will then get appropriately translated into O_* flags if necessary by
> <http://llvm.org/docs/doxygen/html/raw__ostream_8cpp_source.html#l00451>

My idea was to abstract the calls to open. Something like a
sys::fs::openFile which would take llvm flags and translate them to
open flags (similar to what the raw_fd_ostream constructor does). The
problem with the getter is that I need raw_fd_ostream to not close the
fd, which is a bit odd when it was the one that called open. What do
you think?

> -- Sean Silva

Cheers,
Rafael



More information about the llvm-commits mailing list