[PATCH] D28162: [ADT] Delete RefCountedBaseVPTR.

Justin Lebar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 29 10:37:58 PST 2016


jlebar created this revision.
jlebar added reviewers: compnerd, dblaikie.
jlebar added subscribers: llvm-commits, cfe-commits.
Herald added subscribers: mgorny, klimek.

This class is unnecessary.

Its comment indicated that it was a compile error to allocate an
instance of a class that inherits from RefCountedBaseVPTR on the stack.
This may have been true at one point, but it's not today.

Moreover you really do not want to allocate *any* refcounted object on
the stack, vptrs or not, so if we did have a way to prevent these
objects from being stack-allocated, we'd want to apply it to regular
RefCountedBase too, obviating the need for a separate RefCountedBaseVPTR
class.

It seems that the main way RefCountedBaseVPTR provides safety is by
making its subclass's destructor virtual.  This may have been helpful at
one point, but these days clang will emit an error if you define a class
with virtual functions that inherits from RefCountedBase but doesn't
have a virtual destructor.


https://reviews.llvm.org/D28162

Files:
  clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
  clang/include/clang/Basic/LLVM.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/IntrusiveRefCntPtr.cpp
  llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28162.82681.patch
Type: text/x-patch
Size: 7542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161229/7a3aa62c/attachment.bin>


More information about the llvm-commits mailing list