[PATCH] Deprecate and remove OwningPtr
Craig Topper
craig.topper at gmail.com
Wed Jun 18 23:53:08 PDT 2014
On Wed, Jun 18, 2014 at 11:33 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:
> On Thu, Jun 19, 2014 at 1:30 AM, Alp Toker <alp at nuanti.com> wrote:
> > The attached patch slaps some deprecation attributes on the OwningPtr
> > classes and removes associated unit tests.
> >
> > I'll follow up and remove the OwningPtr.h header completely a couple of
> days
> > after to provide a last-chance grace period.
>
> "A couple of days" is not exactly a grace period, especially given how
> many folks are at the standards meetings currently. Was this grace
> period discussed at some point?
>
I believe most in tree uses of OwningPtr were removed in March or April.
The last in tree usage was removed by me on May 21. Hopefully by now anyone
even sort of watching the list would know that OwningPtr's days were
numbered.
>
> > commit c68306ca9483bbed6bf49a21da989517f081bef3
> > Author: Alp Toker <alp at nuanti.com>
> > Date: Thu Jun 19 08:09:43 2014 +0300
> >
> > Deprecate OwningPtr pending imminent removal
> >
> > diff --git a/include/llvm/ADT/OwningPtr.h b/include/llvm/ADT/OwningPtr.h
> > index 5e83358..02ad512 100644
> > --- a/include/llvm/ADT/OwningPtr.h
> > +++ b/include/llvm/ADT/OwningPtr.h
> > @@ -26,7 +26,7 @@ namespace llvm {
> > /// OwningPtr or via an explicit reset(). Once created, ownership of
> the
> > /// pointee object can be taken away from OwningPtr by using the take
> method.
> > template<class T>
> > -class OwningPtr {
> > +class [[deprecated]] OwningPtr {
>
> Not all of our supported compilers also supports C++11-style
> attributes, so this approach is untenable.
>
> > OwningPtr(OwningPtr const &) LLVM_DELETED_FUNCTION;
> > OwningPtr &operator=(OwningPtr const &) LLVM_DELETED_FUNCTION;
> > T *Ptr;
> > @@ -96,6 +96,7 @@ public:
> > };
> >
> > template<class T>
> > +[[deprecated]]
> > inline void swap(OwningPtr<T> &a, OwningPtr<T> &b) {
> > a.swap(b);
> > }
> > @@ -103,7 +104,7 @@ inline void swap(OwningPtr<T> &a, OwningPtr<T> &b) {
> > /// OwningArrayPtr smart pointer - OwningArrayPtr provides the same
> > /// functionality as OwningPtr, except that it works for array types.
> > template<class T>
> > -class OwningArrayPtr {
> > +class [[deprecated]] OwningArrayPtr {
> > OwningArrayPtr(OwningArrayPtr const &) LLVM_DELETED_FUNCTION;
> > OwningArrayPtr &operator=(OwningArrayPtr const &)
> LLVM_DELETED_FUNCTION;
> > T *Ptr;
> > @@ -156,6 +157,7 @@ public:
> > };
> >
> > template<class T>
> > +[[deprecated]]
> > inline void swap(OwningArrayPtr<T> &a, OwningArrayPtr<T> &b) {
> > a.swap(b);
> > }
> > diff --git a/unittests/ADT/CMakeLists.txt b/unittests/ADT/CMakeLists.txt
> > index 5119723..0f214f3 100644
> > --- a/unittests/ADT/CMakeLists.txt
> > +++ b/unittests/ADT/CMakeLists.txt
> > @@ -23,7 +23,6 @@ set(ADTSources
> > MakeUniqueTest.cpp
> > MapVectorTest.cpp
> > OptionalTest.cpp
> > - OwningPtrTest.cpp
> > PackedVectorTest.cpp
> > PointerIntPairTest.cpp
> > PointerUnionTest.cpp
> > diff --git a/unittests/ADT/OwningPtrTest.cpp
> b/unittests/ADT/OwningPtrTest.cpp
> > deleted file mode 100644
> > index d83a947..0000000
> > --- a/unittests/ADT/OwningPtrTest.cpp
> > +++ /dev/null
> > @@ -1,273 +0,0 @@
> > -//===- llvm/unittest/ADT/OwningPtrTest.cpp - OwningPtr unit tests
> ---------===//
> > -//
> > -// The LLVM Compiler Infrastructure
> > -//
> > -// This file is distributed under the University of Illinois Open Source
> > -// License. See LICENSE.TXT for details.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#include "llvm/ADT/OwningPtr.h"
> > -#include "gtest/gtest.h"
> > -using namespace llvm;
> > -
> > -namespace {
> > -
> > -struct TrackDestructor {
> > - static unsigned Destructions;
> > - int val;
> > - explicit TrackDestructor(int val) : val(val) {}
> > - ~TrackDestructor() { ++Destructions; }
> > - static void ResetCounts() { Destructions = 0; }
> > -
> > -private:
> > - TrackDestructor(const TrackDestructor &other) LLVM_DELETED_FUNCTION;
> > - TrackDestructor &
> > - operator=(const TrackDestructor &other) LLVM_DELETED_FUNCTION;
> > - TrackDestructor(TrackDestructor &&other) LLVM_DELETED_FUNCTION;
> > - TrackDestructor &operator=(TrackDestructor &&other)
> LLVM_DELETED_FUNCTION;
> > -};
> > -
> > -unsigned TrackDestructor::Destructions = 0;
> > -
> > -// Test fixture
> > -class OwningPtrTest : public testing::Test {};
> > -
> > -TEST_F(OwningPtrTest, DefaultConstruction) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> O;
> > - EXPECT_FALSE(O);
> > - EXPECT_TRUE(!O);
> > - EXPECT_FALSE(O.get());
> > - EXPECT_FALSE(O.isValid());
> > - }
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, PtrConstruction) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> O(new TrackDestructor(3));
> > - EXPECT_TRUE((bool)O);
> > - EXPECT_FALSE(!O);
> > - EXPECT_TRUE(O.get());
> > - EXPECT_TRUE(O.isValid());
> > - EXPECT_EQ(3, (*O).val);
> > - EXPECT_EQ(3, O->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, Reset) {
> > - TrackDestructor::ResetCounts();
> > - OwningPtr<TrackDestructor> O(new TrackDestructor(3));
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - O.reset();
> > - EXPECT_FALSE((bool)O);
> > - EXPECT_TRUE(!O);
> > - EXPECT_FALSE(O.get());
> > - EXPECT_FALSE(O.isValid());
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, Take) {
> > - TrackDestructor::ResetCounts();
> > - TrackDestructor *T = nullptr;
> > - {
> > - OwningPtr<TrackDestructor> O(new TrackDestructor(3));
> > - T = O.take();
> > - EXPECT_FALSE((bool)O);
> > - EXPECT_TRUE(!O);
> > - EXPECT_FALSE(O.get());
> > - EXPECT_FALSE(O.isValid());
> > - EXPECT_TRUE(T);
> > - EXPECT_EQ(3, T->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - delete T;
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, Release) {
> > - TrackDestructor::ResetCounts();
> > - TrackDestructor *T = nullptr;
> > - {
> > - OwningPtr<TrackDestructor> O(new TrackDestructor(3));
> > - T = O.release();
> > - EXPECT_FALSE((bool)O);
> > - EXPECT_TRUE(!O);
> > - EXPECT_FALSE(O.get());
> > - EXPECT_FALSE(O.isValid());
> > - EXPECT_TRUE(T);
> > - EXPECT_EQ(3, T->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - delete T;
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, MoveConstruction) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> A(new TrackDestructor(3));
> > - OwningPtr<TrackDestructor> B = std::move(A);
> > - EXPECT_FALSE((bool)A);
> > - EXPECT_TRUE(!A);
> > - EXPECT_FALSE(A.get());
> > - EXPECT_FALSE(A.isValid());
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_TRUE(B.isValid());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, MoveAssignment) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> A(new TrackDestructor(3));
> > - OwningPtr<TrackDestructor> B(new TrackDestructor(4));
> > - B = std::move(A);
> > - EXPECT_FALSE(A);
> > - EXPECT_TRUE(!A);
> > - EXPECT_FALSE(A.get());
> > - EXPECT_FALSE(A.isValid());
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_TRUE(B.isValid());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(2u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, Swap) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> A(new TrackDestructor(3));
> > - OwningPtr<TrackDestructor> B(new TrackDestructor(4));
> > - B.swap(A);
> > - EXPECT_TRUE((bool)A);
> > - EXPECT_FALSE(!A);
> > - EXPECT_TRUE(A.get());
> > - EXPECT_TRUE(A.isValid());
> > - EXPECT_EQ(4, (*A).val);
> > - EXPECT_EQ(4, A->val);
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_TRUE(B.isValid());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(2u, TrackDestructor::Destructions);
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> A(new TrackDestructor(3));
> > - OwningPtr<TrackDestructor> B(new TrackDestructor(4));
> > - swap(A, B);
> > - EXPECT_TRUE((bool)A);
> > - EXPECT_FALSE(!A);
> > - EXPECT_TRUE(A.get());
> > - EXPECT_TRUE(A.isValid());
> > - EXPECT_EQ(4, (*A).val);
> > - EXPECT_EQ(4, A->val);
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_TRUE(B.isValid());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(2u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, UniqueToOwningConstruction) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - std::unique_ptr<TrackDestructor> A(new TrackDestructor(3));
> > - OwningPtr<TrackDestructor> B = std::move(A);
> > - EXPECT_FALSE(A);
> > - EXPECT_TRUE(!A);
> > - EXPECT_FALSE(A.get());
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_TRUE(B.isValid());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, UniqueToOwningAssignment) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - std::unique_ptr<TrackDestructor> A(new TrackDestructor(3));
> > - OwningPtr<TrackDestructor> B(new TrackDestructor(4));
> > - B = std::move(A);
> > - EXPECT_FALSE(A);
> > - EXPECT_TRUE(!A);
> > - EXPECT_FALSE(A.get());
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_TRUE(B.isValid());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(2u, TrackDestructor::Destructions);
> > -}
> > -
> > -TEST_F(OwningPtrTest, TakeUniqueConstruction) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> A(new TrackDestructor(3));
> > - std::unique_ptr<TrackDestructor> B = A.take_unique();
> > - EXPECT_FALSE(A);
> > - EXPECT_TRUE(!A);
> > - EXPECT_FALSE(A.get());
> > - EXPECT_FALSE(A.isValid());
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -
> > -#if LLVM_HAS_RVALUE_REFERENCE_THIS
> > -TEST_F(OwningPtrTest, OwningToUniqueConstruction) {
> > - TrackDestructor::ResetCounts();
> > - {
> > - OwningPtr<TrackDestructor> A(new TrackDestructor(3));
> > - std::unique_ptr<TrackDestructor> B = std::move(A);
> > - EXPECT_FALSE(A);
> > - EXPECT_TRUE(!A);
> > - EXPECT_FALSE(A.get());
> > - EXPECT_FALSE(A.isValid());
> > - EXPECT_TRUE((bool)B);
> > - EXPECT_FALSE(!B);
> > - EXPECT_TRUE(B.get());
> > - EXPECT_EQ(3, (*B).val);
> > - EXPECT_EQ(3, B->val);
> > - EXPECT_EQ(0u, TrackDestructor::Destructions);
> > - }
> > - EXPECT_EQ(1u, TrackDestructor::Destructions);
> > -}
> > -#endif
> > -}
> >
>
> ~Aaron
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140618/70264326/attachment.html>
More information about the llvm-commits
mailing list