[all-commits] [llvm/llvm-project] dc361d: [llvm] Add asserts in (ThreadSafe)?RefCountedBase ...

Nathan James via All-commits all-commits at lists.llvm.org
Mon Dec 7 12:25:08 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: dc361d5c2a2dd34839ff4cd48844cf1bf9a87c62
      https://github.com/llvm/llvm-project/commit/dc361d5c2a2dd34839ff4cd48844cf1bf9a87c62
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2020-12-07 (Mon, 07 Dec 2020)

  Changed paths:
    M clang/lib/ASTMatchers/ASTMatchersInternal.cpp
    M llvm/include/llvm/ADT/IntrusiveRefCntPtr.h

  Log Message:
  -----------
  [llvm] Add asserts in (ThreadSafe)?RefCountedBase destructors

Added a trivial destructor in release mode and in debug mode a destructor that asserts RefCount is indeed zero.
This ensure people aren't manually (maybe accidentally) destroying these objects like in this contrived example.
```lang=c++
{
  std::unique_ptr<SomethingRefCounted> Object;
  holdIntrusiveOwnership(Object.get());
  // Object Destructor called here will assert.
}
```

Reviewed By: dblaikie

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




More information about the All-commits mailing list