[PATCH] D28245: ADT: IntrusiveRefCntPtr: Broaden the definition of correct usage of RefCountedBase

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 11:38:15 PST 2017


dblaikie created this revision.
dblaikie added a reviewer: jlebar.
dblaikie added a subscriber: llvm-commits.

This roughly matches the semantics of std::enable_shared_from_this - that it
does not dictate the ownership model of all users, but constrains those users
taking advantage of the intrusive nature to do so only when there's a guarantee
that that's the ownership model being used for the object being passed.


https://reviews.llvm.org/D28245

Files:
  include/llvm/ADT/IntrusiveRefCntPtr.h


Index: include/llvm/ADT/IntrusiveRefCntPtr.h
===================================================================
--- include/llvm/ADT/IntrusiveRefCntPtr.h
+++ include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -69,8 +69,9 @@
 /// refcount, respectively.  When a Release() call decrements the refcount to 0,
 /// the object deletes itself.
 ///
-/// Objects that inherit from RefCountedBase should always be allocated with
-/// operator new.
+/// Don't mix ownership semantics for a given object - only use Retain if you
+/// have exclusive ownership of an object created with 'new', or there are
+/// existing Retained ownerships.
 template <class Derived> class RefCountedBase {
   mutable unsigned RefCount = 0;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28245.82921.patch
Type: text/x-patch
Size: 706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170103/a45c49b2/attachment.bin>


More information about the llvm-commits mailing list