From 7be03cc782d090b960f3f9ed9fe4aa6f3b47e5f5 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 10 Aug 2021 12:44:20 -0400 Subject: [PATCH] [libc++] Remove _LIBCPP_HAS_NO_IS_AGGREGATE All supported compilers have been supporting __is_aggregate for a long time now, so it's reasonable to remove this workaround. Differential Revision: https://reviews.llvm.org/D107833 --- libcxx/include/__config | 4 -- libcxx/include/type_traits | 4 +- libcxx/include/version | 4 +- ...issing_is_aggregate_trait.compile.fail.cpp | 29 ----------- .../type_traits.version.pass.cpp | 48 ++++++------------- .../version.version.pass.cpp | 48 ++++++------------- .../meta.unary.prop/is_aggregate.pass.cpp | 4 -- .../generate_feature_test_macro_components.py | 2 - 8 files changed, 33 insertions(+), 110 deletions(-) delete mode 100644 libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.compile.fail.cpp diff --git a/libcxx/include/__config b/libcxx/include/__config index f9c65cbbaff5..a0b645c891fa 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1363,10 +1363,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( #define _LIBCPP_HAS_NO_DEDUCTION_GUIDES #endif -#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) -#define _LIBCPP_HAS_NO_IS_AGGREGATE -#endif - #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L #define _LIBCPP_HAS_NO_COROUTINES #endif diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 04132e3dd577..0d060b6578da 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1681,7 +1681,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v #endif // is_aggregate -#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) +#if _LIBCPP_STD_VER > 14 template struct _LIBCPP_TEMPLATE_VIS is_aggregate : public integral_constant {}; @@ -1692,7 +1692,7 @@ _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; #endif -#endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) +#endif // _LIBCPP_STD_VER > 14 // is_base_of diff --git a/libcxx/include/version b/libcxx/include/version index 6adea75405be..ce094f88b1cd 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -228,9 +228,7 @@ __cpp_lib_void_t 201411L # define __cpp_lib_hypot 201603L # define __cpp_lib_incomplete_container_elements 201505L # define __cpp_lib_invoke 201411L -# if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) -# define __cpp_lib_is_aggregate 201703L -# endif +# define __cpp_lib_is_aggregate 201703L # define __cpp_lib_is_invocable 201703L # define __cpp_lib_is_swappable 201603L # define __cpp_lib_launder 201606L diff --git a/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.compile.fail.cpp b/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.compile.fail.cpp deleted file mode 100644 index 183019cf7b38..000000000000 --- a/libcxx/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.compile.fail.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 - -// - -// template struct is_aggregate; -// template constexpr bool is_aggregate_v = is_aggregate::value; - -#include - -int main(int, char**) -{ -#ifdef _LIBCPP_HAS_NO_IS_AGGREGATE - // This should not compile when _LIBCPP_HAS_NO_IS_AGGREGATE is defined. - bool b = __is_aggregate(void); - ((void)b); -#else -#error Forcing failure... -#endif - - return 0; -} diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp index c97a48b7b30c..1e270d3739fd 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp @@ -253,17 +253,11 @@ # error "__cpp_lib_integral_constant_callable should have the value 201304L in c++17" # endif -# if TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 -# ifndef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should be defined in c++17" -# endif -# if __cpp_lib_is_aggregate != 201703L -# error "__cpp_lib_is_aggregate should have the value 201703L in c++17" -# endif -# else -# ifdef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 is not defined!" -# endif +# ifndef __cpp_lib_is_aggregate +# error "__cpp_lib_is_aggregate should be defined in c++17" +# endif +# if __cpp_lib_is_aggregate != 201703L +# error "__cpp_lib_is_aggregate should have the value 201703L in c++17" # endif # ifdef __cpp_lib_is_constant_evaluated @@ -389,17 +383,11 @@ # error "__cpp_lib_integral_constant_callable should have the value 201304L in c++20" # endif -# if TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 -# ifndef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should be defined in c++20" -# endif -# if __cpp_lib_is_aggregate != 201703L -# error "__cpp_lib_is_aggregate should have the value 201703L in c++20" -# endif -# else -# ifdef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 is not defined!" -# endif +# ifndef __cpp_lib_is_aggregate +# error "__cpp_lib_is_aggregate should be defined in c++20" +# endif +# if __cpp_lib_is_aggregate != 201703L +# error "__cpp_lib_is_aggregate should have the value 201703L in c++20" # endif # ifndef __cpp_lib_is_constant_evaluated @@ -552,17 +540,11 @@ # error "__cpp_lib_integral_constant_callable should have the value 201304L in c++2b" # endif -# if TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 -# ifndef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should be defined in c++2b" -# endif -# if __cpp_lib_is_aggregate != 201703L -# error "__cpp_lib_is_aggregate should have the value 201703L in c++2b" -# endif -# else -# ifdef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 is not defined!" -# endif +# ifndef __cpp_lib_is_aggregate +# error "__cpp_lib_is_aggregate should be defined in c++2b" +# endif +# if __cpp_lib_is_aggregate != 201703L +# error "__cpp_lib_is_aggregate should have the value 201703L in c++2b" # endif # ifndef __cpp_lib_is_constant_evaluated diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp index 82b8d845757b..2c01e79f4bd0 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp @@ -1660,17 +1660,11 @@ # error "__cpp_lib_invoke should have the value 201411L in c++17" # endif -# if TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 -# ifndef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should be defined in c++17" -# endif -# if __cpp_lib_is_aggregate != 201703L -# error "__cpp_lib_is_aggregate should have the value 201703L in c++17" -# endif -# else -# ifdef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 is not defined!" -# endif +# ifndef __cpp_lib_is_aggregate +# error "__cpp_lib_is_aggregate should be defined in c++17" +# endif +# if __cpp_lib_is_aggregate != 201703L +# error "__cpp_lib_is_aggregate should have the value 201703L in c++17" # endif # ifdef __cpp_lib_is_constant_evaluated @@ -2694,17 +2688,11 @@ # error "__cpp_lib_invoke should have the value 201411L in c++20" # endif -# if TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 -# ifndef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should be defined in c++20" -# endif -# if __cpp_lib_is_aggregate != 201703L -# error "__cpp_lib_is_aggregate should have the value 201703L in c++20" -# endif -# else -# ifdef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 is not defined!" -# endif +# ifndef __cpp_lib_is_aggregate +# error "__cpp_lib_is_aggregate should be defined in c++20" +# endif +# if __cpp_lib_is_aggregate != 201703L +# error "__cpp_lib_is_aggregate should have the value 201703L in c++20" # endif # ifndef __cpp_lib_is_constant_evaluated @@ -3869,17 +3857,11 @@ # error "__cpp_lib_invoke should have the value 201411L in c++2b" # endif -# if TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 -# ifndef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should be defined in c++2b" -# endif -# if __cpp_lib_is_aggregate != 201703L -# error "__cpp_lib_is_aggregate should have the value 201703L in c++2b" -# endif -# else -# ifdef __cpp_lib_is_aggregate -# error "__cpp_lib_is_aggregate should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001 is not defined!" -# endif +# ifndef __cpp_lib_is_aggregate +# error "__cpp_lib_is_aggregate should be defined in c++2b" +# endif +# if __cpp_lib_is_aggregate != 201703L +# error "__cpp_lib_is_aggregate should have the value 201703L in c++2b" # endif # ifndef __cpp_lib_is_constant_evaluated diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp index 100c5271a6cd..277e154712f3 100644 --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp @@ -19,7 +19,6 @@ template void test_true() { -#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) static_assert( std::is_aggregate::value, ""); static_assert( std::is_aggregate::value, ""); static_assert( std::is_aggregate::value, ""); @@ -28,13 +27,11 @@ void test_true() static_assert( std::is_aggregate_v, ""); static_assert( std::is_aggregate_v, ""); static_assert( std::is_aggregate_v, ""); -#endif } template void test_false() { -#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) static_assert(!std::is_aggregate::value, ""); static_assert(!std::is_aggregate::value, ""); static_assert(!std::is_aggregate::value, ""); @@ -43,7 +40,6 @@ void test_false() static_assert(!std::is_aggregate_v, ""); static_assert(!std::is_aggregate_v, ""); static_assert(!std::is_aggregate_v, ""); -#endif } struct Aggregate {}; diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 0d2a77da289c..577faa3bbd19 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -363,8 +363,6 @@ feature_test_macros = [ add_version_header(x) for x in [ "name": "__cpp_lib_is_aggregate", "values": { "c++17": 201703 }, "headers": ["type_traits"], - "test_suite_guard": "TEST_HAS_BUILTIN_IDENTIFIER(__is_aggregate) || TEST_GCC_VER_NEW >= 7001", - "libcxx_guard": "!defined(_LIBCPP_HAS_NO_IS_AGGREGATE)", }, { "name": "__cpp_lib_is_constant_evaluated", "values": { "c++20": 201811 },