From 746d46ed860f562d036510f83dd540f57eca3065 Mon Sep 17 00:00:00 2001 From: Diana Picus Date: Thu, 18 Aug 2016 11:17:47 +0000 Subject: [PATCH] Revert "ADT: Tidy up ilist_traits static asserts, NFC" This reverts commit r279012. r278974 broke some bots, I have to revert this to get to it. llvm-svn: 279052 --- include/llvm/ADT/ilist.h | 35 +++++++++++++++++++---------------- unittests/ADT/ilistTest.cpp | 17 ----------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h index c77730c99a3..10ff088dcd6 100644 --- a/include/llvm/ADT/ilist.h +++ b/include/llvm/ADT/ilist.h @@ -83,37 +83,34 @@ 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 class HasGetNext { +template struct HasGetNext { typedef char Yes[1]; typedef char No[2]; template struct SFINAE {}; template - static Yes &test(U *I, decltype(I->getNext(&make())) * = 0); - template static No &test(...); + static Yes &hasGetNext( + SFINAE(make().getNext(&make())))> + * = 0); + template static No &hasGetNext(...); -public: - static const bool value = sizeof(test(nullptr)) == sizeof(Yes); + static const bool value = sizeof(hasGetNext(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 class HasCreateSentinel { +template struct HasCreateSentinel { typedef char Yes[1]; typedef char No[2]; template struct SFINAE {}; template - static Yes &test(U *I, decltype(I->createSentinel()) * = 0); - template static No &test(...); + static Yes & + hasCreateSentinel(SFINAE().createSentinel())> * = 0); + template static No &hasCreateSentinel(...); -public: - static const bool value = sizeof(test(nullptr)) == sizeof(Yes); -}; - -template struct HasObsoleteCustomization { static const bool value = - HasGetNext::value || HasCreateSentinel::value; + sizeof(hasCreateSentinel(nullptr)) == sizeof(Yes); }; } // end namespace ilist_detail @@ -290,8 +287,14 @@ template > class iplist : public Traits, ilist_node_access { // TODO: Drop these assertions anytime after 4.0 is branched (keep them for // one release to help out-of-tree code update). - static_assert(!ilist_detail::HasObsoleteCustomization::value, - "ilist customization points have changed!"); +#if !defined(_MSC_VER) + // FIXME: This fails in MSVC, but it's worth keeping around to help + // non-Windows users root out bugs in their ilist_traits. + static_assert(!ilist_detail::HasGetNext::value, + "ilist next and prev links are not customizable!"); + static_assert(!ilist_detail::HasCreateSentinel::value, + "ilist sentinel is not customizable!"); +#endif ilist_sentinel Sentinel; diff --git a/unittests/ADT/ilistTest.cpp b/unittests/ADT/ilistTest.cpp index 57cdd584ec1..a8ea63ed464 100644 --- a/unittests/ADT/ilistTest.cpp +++ b/unittests/ADT/ilistTest.cpp @@ -190,21 +190,4 @@ TEST(ilistTest, privateNode) { L2.remove(&N); } -struct GetNext { - Node *getNext(Node *); -}; -TEST(ilistTest, HasGetNextTrait) { - EXPECT_TRUE((ilist_detail::HasGetNext::value)); - EXPECT_TRUE((ilist_detail::HasObsoleteCustomization::value)); -} - -struct CreateSentinel { - Node *createSentinel(); -}; -TEST(ilistTest, HasCreateSentinel) { - EXPECT_TRUE((ilist_detail::HasCreateSentinel::value)); - EXPECT_TRUE( - (ilist_detail::HasObsoleteCustomization::value)); -} - } // end namespace