<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 12:06 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't have much to add here besides +1. I think using std::unique_ptr even for create* functions/methods is the right way to go. </blockquote>

<div><br></div><div>+1 smart pointers here are a win in terms of safety and self-documentation. I don't see why create* factories should be treated differently.</div><div><br></div><div>Eli</div><div><br></div><div><br>

</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Reid's point about an abstraction penalty is interesting, but I don't think we do ownership transfers often enough to actually see a performance hit. (Of course, in the non-transferring case we'd just pass the pointer, not a 'const std::unique_ptr &' or anything.)<br>


<span class="HOEnZb"><font color="#888888"><br>
Jordan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Jul 17, 2014, at 16:21 , David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
<br>
> There seems to be some uncertainty about the use of smart pointers<br>
> (previously OwningPtr, now std::unique_ptr and std::shared_ptr<br>
> predominantly) in the LLVM project as a whole, so here's a thread to<br>
> discuss/clarify/etc the project preferences/direction with regard to<br>
> smart pointer usage.<br>
><br>
> For some context, see discussions in LLVM r212403 and Clang r213307.<br>
><br>
> The basic question here seems to be whether smart pointer ownership is<br>
> a direction we want to take the LLVM project in general.<br>
><br>
> I've seen others contribute and have myself contributed many patches<br>
> moving towards smart pointer ownership (both in the pre-C++11 days of<br>
> OwningPtr, and much moreso in the post-C++11 world with<br>
> std::unique_ptr and std::shared_ptr being usable inside containers, as<br>
> return values, etc, allowing many more opportunities).<br>
><br>
> std::unique_ptr's been used in LLD as far back as r153620.<br>
> std::unique_ptr appeared in LLVM shortly after the C++11 switch with<br>
> Ahmed's work to migrate the project from OwningPtr to std::unique_ptr<br>
> (starting with r202609 and ending with r211259). Originally OwningPtr<br>
> was added in r45261.<br>
> Something in the order of 60 changes across clang and LLVM mention<br>
> unique_ptr in their subject and migrate various APIs to use unique_ptr<br>
> for ownership. Many of which remove uses of explicit delete or helpers<br>
> like DeleteContainerPointers (and removing explicit dtors in many of<br>
> those cases).<br>
><br>
> Are people OK with/prefer the use of owning smart pointers in APIs?<br>
> Are there places where you've found them to be too noisy/burdensome<br>
> and would rather use raw pointers or some other abstraction? Would you<br>
> prefer pre-commit review of such changes to adequately consider<br>
> alternatives (such as?)?<br>
><br>
> Thanks,<br>
> - David<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div>