]> granicus.if.org Git - llvm/commitdiff
ADT: IntrusiveRefCntPtr: Broaden the definition of correct usage of RefCountedBase
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 4 Jan 2017 18:57:31 +0000 (18:57 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 4 Jan 2017 18:57:31 +0000 (18:57 +0000)
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.

Reviewers: jlebar

Differential Revision: https://reviews.llvm.org/D28245

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290987 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/IntrusiveRefCntPtr.h

index 559fb40773aaa31100c8c77dbb61a7b03d4d8cb9..a77cf04ea4d1df2ee49021e2613121b02811215f 100644 (file)
@@ -21,8 +21,8 @@
 //   class MyClass : public RefCountedBase<MyClass> {};
 //
 //   void foo() {
-//     // Objects that inherit from RefCountedBase should always be instantiated
-//     // on the heap, never on the stack.
+//     // Constructing an IntrusiveRefCntPtr increases the pointee's refcount by
+//     // 1 (from 0 in this case).
 //     IntrusiveRefCntPtr<MyClass> Ptr1(new MyClass());
 //
 //     // Copying an IntrusiveRefCntPtr increases the pointee's refcount by 1.
@@ -68,9 +68,6 @@ namespace llvm {
 /// calls to Release() and Retain(), which increment and decrement the object's
 /// 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.
 template <class Derived> class RefCountedBase {
   mutable unsigned RefCount = 0;