21 #ifndef LLVM_ADT_INTRUSIVEREFCNTPTR_H
22 #define LLVM_ADT_INTRUSIVEREFCNTPTR_H
43 template <
class Derived>
45 mutable unsigned ref_cnt;
53 assert (ref_cnt > 0 &&
"Reference count is already zero.");
54 if (--ref_cnt == 0)
delete static_cast<const Derived*
>(
this);
67 mutable unsigned ref_cnt;
68 virtual void anchor();
78 assert (ref_cnt > 0 &&
"Reference count is already zero.");
79 if (--ref_cnt == 0)
delete this;
88 static void retain(
T *obj) { obj->Retain(); }
89 static void release(
T *obj) { obj->Release(); }
99 template <
class Derived>
101 mutable std::atomic<int> RefCount;
110 int NewRefCount = --RefCount;
111 assert(NewRefCount >= 0 &&
"Reference count was already zero.");
112 if (NewRefCount == 0)
113 delete static_cast<const Derived*
>(
this);
134 template <
typename T>
135 class IntrusiveRefCntPtr {
177 T*
get()
const {
return Obj; }
179 explicit operator bool()
const {
return Obj; }
200 template <
typename X>
204 template<
class T,
class U>
208 return A.get() == B.get();
211 template<
class T,
class U>
215 return A.get() != B.get();
218 template<
class T,
class U>
225 template<
class T,
class U>
232 template<
class T,
class U>
239 template<
class T,
class U>
270 template <
typename From>
struct simplify_type;
288 #endif // LLVM_ADT_INTRUSIVEREFCNTPTR_H
static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr< T > &Val)
RefCountedBase - A generic base class for objects that wish to have their lifetimes managed using ref...
RefCountedBase(const RefCountedBase &)
ThreadSafeRefCountedBase()
static void release(T *obj)
IntrusiveRefCntPtr - A template class that implements a "smart pointer" that assumes the wrapped obje...
static void retain(T *obj)
RefCountedBaseVPTR - A class that has the same function as RefCountedBase, but with a virtual destruc...
A thread-safe version of llvm::RefCountedBase.
IntrusiveRefCntPtr(const IntrusiveRefCntPtr &S)
bool operator!=(uint64_t V1, const APInt &V2)
IntrusiveRefCntPtr(T *obj)
void swap(IntrusiveRefCntPtr &other)
static SimpleType getSimplifiedValue(IntrusiveRefCntPtr< T > &Val)
IntrusiveRefCntPtr(const IntrusiveRefCntPtr< X > &S)
IntrusiveRefCntPtr(IntrusiveRefCntPtr &&S)
void resetWithoutRelease()
RefCountedBaseVPTR(const RefCountedBaseVPTR &)
virtual ~RefCountedBaseVPTR()
bool operator==(uint64_t V1, const APInt &V2)
IntrusiveRefCntPtr & operator=(IntrusiveRefCntPtr S)
IntrusiveRefCntPtr(IntrusiveRefCntPtr< X > &&S)