From bab6cfede92830bb38d08282c62144df79b13600 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Mon, 24 Apr 2023 22:23:38 -0700 Subject: [PATCH] Remove code only needed to detect a pre-4.0 API break. Updated with build fix for unit tests Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D149125 --- llvm/include/llvm/ADT/ilist.h | 64 ---------------------------------------- llvm/unittests/ADT/IListTest.cpp | 36 ---------------------- 2 files changed, 100 deletions(-) diff --git a/llvm/include/llvm/ADT/ilist.h b/llvm/include/llvm/ADT/ilist.h index 9913b7c..aed19cc 100644 --- a/llvm/include/llvm/ADT/ilist.h +++ b/llvm/include/llvm/ADT/ilist.h @@ -92,63 +92,6 @@ struct ilist_traits : public ilist_node_traits {}; /// Const traits should never be instantiated. template struct ilist_traits {}; -namespace ilist_detail { - -template T &make(); - -/// Type trait to check for a traits class that has a getNext member (as a -/// canary for any of the ilist_nextprev_traits API). -template struct HasGetNext { - typedef char Yes[1]; - typedef char No[2]; - template struct SFINAE {}; - - template - static Yes &test(U *I, decltype(I->getNext(&make())) * = nullptr); - template static No &test(...); - -public: - static const bool value = sizeof(test(nullptr)) == sizeof(Yes); -}; - -/// Type trait to check for a traits class that has a createSentinel member (as -/// a canary for any of the ilist_sentinel_traits API). -template struct HasCreateSentinel { - typedef char Yes[1]; - typedef char No[2]; - - template - static Yes &test(U *I, decltype(I->createSentinel()) * = nullptr); - template static No &test(...); - -public: - static const bool value = sizeof(test(nullptr)) == sizeof(Yes); -}; - -/// Type trait to check for a traits class that has a createNode member. -/// Allocation should be managed in a wrapper class, instead of in -/// ilist_traits. -template struct HasCreateNode { - typedef char Yes[1]; - typedef char No[2]; - template struct SFINAE {}; - - template - static Yes &test(U *I, decltype(I->createNode(make())) * = 0); - template static No &test(...); - -public: - static const bool value = sizeof(test(nullptr)) == sizeof(Yes); -}; - -template struct HasObsoleteCustomization { - static const bool value = HasGetNext::value || - HasCreateSentinel::value || - HasCreateNode::value; -}; - -} // end namespace ilist_detail - //===----------------------------------------------------------------------===// // /// A wrapper around an intrusive list with callbacks and non-intrusive @@ -182,13 +125,6 @@ public: typename base_list_type::const_reverse_iterator const_reverse_iterator; private: - // TODO: Drop this assertion and the transitive type traits anytime after - // v4.0 is branched (i.e,. keep them for one release to help out-of-tree code - // update). - static_assert( - !ilist_detail::HasObsoleteCustomization::value, - "ilist customization points have changed!"); - static bool op_less(const_reference L, const_reference R) { return L < R; } static bool op_equal(const_reference L, const_reference R) { return L == R; } diff --git a/llvm/unittests/ADT/IListTest.cpp b/llvm/unittests/ADT/IListTest.cpp index 18f6c41..2fdc8e1 100644 --- a/llvm/unittests/ADT/IListTest.cpp +++ b/llvm/unittests/ADT/IListTest.cpp @@ -158,42 +158,6 @@ TEST(IListTest, UnsafeClear) { EXPECT_EQ(6, List.back().Value); } -struct Empty {}; -TEST(IListTest, HasObsoleteCustomizationTrait) { - // Negative test for HasObsoleteCustomization. - static_assert(!ilist_detail::HasObsoleteCustomization::value, - "Empty has no customizations"); -} - -struct GetNext { - Node *getNext(Node *); -}; -TEST(IListTest, HasGetNextTrait) { - static_assert(ilist_detail::HasGetNext::value, - "GetNext has a getNext(Node*)"); - static_assert(ilist_detail::HasObsoleteCustomization::value, - "Empty should be obsolete because of getNext()"); - - // Negative test for HasGetNext. - static_assert(!ilist_detail::HasGetNext::value, - "Empty does not have a getNext(Node*)"); -} - -struct CreateSentinel { - Node *createSentinel(); -}; -TEST(IListTest, HasCreateSentinelTrait) { - static_assert(ilist_detail::HasCreateSentinel::value, - "CreateSentinel has a getNext(Node*)"); - static_assert( - ilist_detail::HasObsoleteCustomization::value, - "Empty should be obsolete because of createSentinel()"); - - // Negative test for HasCreateSentinel. - static_assert(!ilist_detail::HasCreateSentinel::value, - "Empty does not have a createSentinel()"); -} - struct NodeWithCallback : ilist_node { int Value = 0; bool IsInList = false; -- 2.7.4