<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 4, 2014 at 3:39 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="">> Hi Rafael,<br>
><br>
> It doesn't make much sense to me that these objects own the buffer. After<br>
> all they only read from the buffer, and there's no reason why it shouldn't<br>
> be shared.<br>
<br>
</div>In a way that is true, but then they should *never* delete the buffer.<br>
The old situation where they would sometimes own it was very error<br>
prone.<br>
<div class=""><br>
> As an implementation detail, it's OK if they delete the buffer for now<br>
> (r211542 is fantastic) but I'm not at all keen on expressing that in the<br>
> interface because it ends up formalizing what's really a flaw in the<br>
> implementation.<br>
<br>
</div>Well, we should have an interface that makes the ownership clear. If<br>
it possible to make them never own the buffer, that would be awesome.<br>
Once that is the case the constructors should probably be changed to<br>
even take a StringRef and a name instead of MemoryBuffer, but if they<br>
own what they point to then a unique_ptr is the correct interface<br>
IMHO.<br>
<br>
Would passing a pair of StringRefs (Data and Name) work for you?<br></blockquote><div><br></div><div>That seems like the natural API.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class=""><br>
> I have a changeset that makes these objects use the MemoryBuffer without<br>
> deleting it, but r211595 and r211546 get in the way of the approach by<br>
> making the interface require unique ownership.<br>
><br>
> (I was expecting the underlying changes to land well before now which is why<br>
> I didn't speak up earlier, could you take a look at<br>
> <a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140630/224492.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140630/224492.html</a><br>
> ?)<br>
<br>
</div>I consider reference counting to be the lest desirable option of all.<br>
It makes it incredibly hard to reason about the ownership, even more<br>
so than the old "owned" bool.<br>
<br>
Cheers,<br>
Rafael<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>