<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">+1. I think there is a lot of value in using standard library's smart pointers over custom smart pointers or raw pointers where the callers are expected to understand the object’s lifetime. They communicate the intended semantics to users (leading to less errors), and because they are broadly used and well defined they will be more amenable to tooling both debugging and optimization advances in the future.<div><br></div><div>Louis<br><div><br></div><div><div><blockquote type="cite"><div>On Jul 17, 2014, at 4:43 PM, Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div>Where unique_ptr fits the memory ownership model I'm all for using it. The syntactic overhead is a small price to pay for self-documentation and compile-time guarantees.</div><div><br></div><div>What are the objections?</div>
<div><br></div><div>Cheers,</div><div>Lang.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 17, 2014 at 4:21 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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>
</blockquote></div><br></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></div></div></body></html>