X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FIntrusiveRefCntPtr.h;h=0c02a8f318543b651ddb1076733245a9c5cdb015;hb=40dab1059e72d3af59f2523fa8a7d05f40dafca5;hp=3a1a3f4634cfdc4dbe53ce4b439386ed159368b9;hpb=41aa108f743ed3b97cdf060ae25cfef38af5bc9e;p=oota-llvm.git diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index 3a1a3f4634c..0c02a8f3185 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -21,9 +21,9 @@ #ifndef LLVM_ADT_INTRUSIVE_REF_CNT_PTR #define LLVM_ADT_INTRUSIVE_REF_CNT_PTR -#include - #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" +#include namespace llvm { @@ -123,25 +123,25 @@ namespace llvm { retain(); } - template - IntrusiveRefCntPtr(const IntrusiveRefCntPtr& S) - : Obj(S.getPtr()) { - retain(); +#if LLVM_USE_RVALUE_REFERENCES + IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.Obj) { + S.Obj = 0; } - IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) { - replace(S.getPtr()); - return *this; + template + IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.getPtr()) { + S.Obj = 0; } +#endif template - IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) { - replace(S.getPtr()); - return *this; + IntrusiveRefCntPtr(const IntrusiveRefCntPtr& S) + : Obj(S.getPtr()) { + retain(); } - IntrusiveRefCntPtr& operator=(T * S) { - replace(S); + IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr S) { + swap(S); return *this; } @@ -176,10 +176,6 @@ namespace llvm { private: void retain() { if (Obj) IntrusiveRefCntPtrInfo::retain(Obj); } void release() { if (Obj) IntrusiveRefCntPtrInfo::release(Obj); } - - void replace(T* S) { - this_type(S).swap(*this); - } }; template