<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 12, 2013 at 9:30 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 12 July 2013 22:16, Sean Silva <<a href="mailto:silvas@purdue.edu">silvas@purdue.edu</a>> wrote:<br>

> The raw calls to open/close in this code (and the corresponding #ifdef's)<br>
> make me sad. It seems like the whole reason that this code is using raw<br>
> calls to open() and close() is because of<br>
><br>
> 1. This call to sys::fs::setLastModificationAndAccessTime, which needs the<br>
> FD. Would it be possible to add a getter to raw_fd_ostream for getting the<br>
> FD? Then you could use tool_output_file.os().get_fd() instead of keeping the<br>
> FD around explicitly.<br>
><br>
> 2. Setting the mode. It seems like we could just add an extra argument<br>
> (defaulted to 0644) to raw_fd_ostream's constructor, which can then just<br>
> pass it in on the call<br>
> <<a href="http://llvm.org/docs/doxygen/html/raw__ostream_8cpp_source.html#l00464" target="_blank">http://llvm.org/docs/doxygen/html/raw__ostream_8cpp_source.html#l00464</a>>.<br>
><br>
> Also can we use tool_output_file here (after adding a default parameter to<br>
> the constructor that gets passed though to raw_fd_ostream's constructor)?<br>
><br>
> Also, for the O_* constants above, you can use the corresponding F_* flags<br>
> which will then get appropriately translated into O_* flags if necessary by<br>
> <<a href="http://llvm.org/docs/doxygen/html/raw__ostream_8cpp_source.html#l00451" target="_blank">http://llvm.org/docs/doxygen/html/raw__ostream_8cpp_source.html#l00451</a>><br>
<br>
</div></div>My idea was to abstract the calls to open. Something like a<br>
sys::fs::openFile which would take llvm flags and translate them to<br>
open flags (similar to what the raw_fd_ostream constructor does). The<br>
problem with the getter is that I need raw_fd_ostream to not close the<br>
fd, which is a bit odd when it was the one that called open. What do<br>
you think?<br></blockquote><div><br></div><div>I'm not sure I understand. The code calls close(FD) at the end of the function, so presumably the raw_fd_ostream could just be moved out of the block it is currently in?</div>
<div><br></div><div>-- Sean Silva </div></div></div></div>