diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index 947ccc46a52..37018d95e60 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -23,6 +23,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" +#include namespace llvm { @@ -146,15 +147,13 @@ namespace llvm { #if LLVM_USE_RVALUE_REFERENCES IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) { - Obj = S.Obj; - S.Obj = 0; + this_type(std::move(S)).swap(*this); return *this; } template IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) { - Obj = S.getPtr(); - S.Obj = 0; + this_type(std::move(S)).swap(*this); return *this; } #endif