[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 2 18:41:45 PST 2020
njames93 added a comment.
I've added test cases which demonstrate what these copies/moves are about.
The move constructor probably would never get used. I can't see of a reason to move the contents of a ref counted pointer. In which case there could be an argument to delete it.
The copy constructor OTOH is very likely to be used (which i think is the reason its currently defined in RefCountedBase).
Adding the CopyAssignment and MoveAssignment operators are there to make sure the compiler wont define them implicitly, copying the ref count.
================
Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-76
RefCountedBase() = default;
+ // Copy and move constructors/assignments are no-ops as the RefCount isn't
+ // dictated by the class directly.
RefCountedBase(const RefCountedBase &) {}
----------------
njames93 wrote:
> dexonsmith wrote:
> > dblaikie wrote:
> > > I can't quite understand this comment - perhaps you could try rephrasing it?
> > I'm not quite following why you needed to add these special members; it seems like just the destructor would be enough for the assertion; but if you do need them, can/should they be `= default`?
> They can't be defaulted as we don't want to copy the RefCount.
I understand it in my head, just can't think of the best way to write it down.
================
Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-80
+ // Copy and move constructors/assignments are no-ops as the RefCount isn't
+ // dictated by the class directly.
RefCountedBase(const RefCountedBase &) {}
+ RefCountedBase(RefCountedBase &&) {}
+ RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+ RefCountedBase &operator=(RefCountedBase &&) { return *this; }
----------------
dexonsmith wrote:
> dblaikie wrote:
> > I can't quite understand this comment - perhaps you could try rephrasing it?
> I'm not quite following why you needed to add these special members; it seems like just the destructor would be enough for the assertion; but if you do need them, can/should they be `= default`?
They can't be defaulted as we don't want to copy the RefCount.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92480/new/
https://reviews.llvm.org/D92480
More information about the cfe-commits
mailing list