From cef39256986150d6e7d6d87ea36077452f045c50 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Jan 2012 08:19:57 +0000 Subject: [PATCH] allow OwningPtr to be copy constructed if null, which is required to make them be a valuetype in a DenseMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148688 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/OwningPtr.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/llvm/ADT/OwningPtr.h b/include/llvm/ADT/OwningPtr.h index 6d9c3059778..e82ebc7b049 100644 --- a/include/llvm/ADT/OwningPtr.h +++ b/include/llvm/ADT/OwningPtr.h @@ -25,12 +25,15 @@ namespace llvm { /// pointee object can be taken away from OwningPtr by using the take method. template class OwningPtr { - OwningPtr(OwningPtr const &); // DO NOT IMPLEMENT - OwningPtr &operator=(OwningPtr const &); // DO NOT IMPLEMENT + OwningPtr &operator=(const OwningPtr &); // DO NOT IMPLEMENT T *Ptr; public: explicit OwningPtr(T *P = 0) : Ptr(P) {} + OwningPtr(const OwningPtr &RHS) : Ptr(0) { + assert(RHS.Ptr == 0 && "Only null OwningPtr's are copyable!"); + } + ~OwningPtr() { delete Ptr; }