From e4dd614ae81194b0a50361a91f8bd4364916ef2e Mon Sep 17 00:00:00 2001 From: Christopher Di Bella Date: Fri, 19 Feb 2021 01:54:52 +0000 Subject: [PATCH] [libcxx] cleans up __cpp_concepts mess libc++ was previously a bit confused by what the value of __cpp_concepts should be. Also replaces `__floating_point` with `floating_point` now that it exists. Differential Revision: https://reviews.llvm.org/D97015 --- libcxx/include/concepts | 4 +-- libcxx/include/numbers | 34 ++++++++++------------ libcxx/include/random | 4 +-- libcxx/include/version | 2 +- .../numbers.version.pass.cpp | 12 ++++---- .../version.version.pass.cpp | 12 ++++---- .../generate_feature_test_macro_components.py | 4 +-- libcxx/utils/libcxx/test/features.py | 2 +- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/libcxx/include/concepts b/libcxx/include/concepts index dac6b69..3d57c40 100644 --- a/libcxx/include/concepts +++ b/libcxx/include/concepts @@ -149,7 +149,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) // [concept.same] @@ -228,7 +228,7 @@ concept invocable = requires(_Fn&& __fn, _Args&&... __args) { template concept regular_invocable = invocable<_Fn, _Args...>; -#endif // _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/numbers b/libcxx/include/numbers index 38dad99..e5172af 100644 --- a/libcxx/include/numbers +++ b/libcxx/include/numbers @@ -60,8 +60,9 @@ namespace std::numbers { #include <__config> -#if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) +#include #include #include @@ -99,22 +100,19 @@ template inline constexpr T inv_sqrt3_v = __illformed{}; template inline constexpr T egamma_v = __illformed{}; template inline constexpr T phi_v = __illformed{}; -template -concept __floating_point = is_floating_point_v; - -template <__floating_point T> inline constexpr T e_v = 2.718281828459045235360287471352662; -template <__floating_point T> inline constexpr T log2e_v = 1.442695040888963407359924681001892; -template <__floating_point T> inline constexpr T log10e_v = 0.434294481903251827651128918916605; -template <__floating_point T> inline constexpr T pi_v = 3.141592653589793238462643383279502; -template <__floating_point T> inline constexpr T inv_pi_v = 0.318309886183790671537767526745028; -template <__floating_point T> inline constexpr T inv_sqrtpi_v = 0.564189583547756286948079451560772; -template <__floating_point T> inline constexpr T ln2_v = 0.693147180559945309417232121458176; -template <__floating_point T> inline constexpr T ln10_v = 2.302585092994045684017991454684364; -template <__floating_point T> inline constexpr T sqrt2_v = 1.414213562373095048801688724209698; -template <__floating_point T> inline constexpr T sqrt3_v = 1.732050807568877293527446341505872; -template <__floating_point T> inline constexpr T inv_sqrt3_v = 0.577350269189625764509148780501957; -template <__floating_point T> inline constexpr T egamma_v = 0.577215664901532860606512090082402; -template <__floating_point T> inline constexpr T phi_v = 1.618033988749894848204586834365638; +template inline constexpr T e_v = 2.718281828459045235360287471352662; +template inline constexpr T log2e_v = 1.442695040888963407359924681001892; +template inline constexpr T log10e_v = 0.434294481903251827651128918916605; +template inline constexpr T pi_v = 3.141592653589793238462643383279502; +template inline constexpr T inv_pi_v = 0.318309886183790671537767526745028; +template inline constexpr T inv_sqrtpi_v = 0.564189583547756286948079451560772; +template inline constexpr T ln2_v = 0.693147180559945309417232121458176; +template inline constexpr T ln10_v = 2.302585092994045684017991454684364; +template inline constexpr T sqrt2_v = 1.414213562373095048801688724209698; +template inline constexpr T sqrt3_v = 1.732050807568877293527446341505872; +template inline constexpr T inv_sqrt3_v = 0.577350269189625764509148780501957; +template inline constexpr T egamma_v = 0.577215664901532860606512090082402; +template inline constexpr T phi_v = 1.618033988749894848204586834365638; inline constexpr double e = e_v; inline constexpr double log2e = log2e_v; @@ -136,6 +134,6 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L +#endif //_LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) #endif // _LIBCPP_NUMBERS diff --git a/libcxx/include/random b/libcxx/include/random index 1cbe9b5..a2f45ba 100644 --- a/libcxx/include/random +++ b/libcxx/include/random @@ -1701,7 +1701,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) // [rand.req.urng] template @@ -1713,7 +1713,7 @@ concept uniform_random_bit_generator = requires bool_constant<(_Gen::min() < _Gen::max())>::value; }; -#endif // _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) // __is_seed_sequence diff --git a/libcxx/include/version b/libcxx/include/version index 3252219..e869723 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -336,7 +336,7 @@ __cpp_lib_void_t 201411L # define __cpp_lib_latch 201907L # endif # define __cpp_lib_list_remove_return_type 201806L -# if defined(__cpp_concepts) && __cpp_concepts >= 201811L +# ifndef _LIBCPP_HAS_NO_CONCEPTS # define __cpp_lib_math_constants 201907L # endif // # define __cpp_lib_polymorphic_allocator 201902L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp index 9e6b1fa..aaa64d1 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp @@ -42,7 +42,7 @@ #elif TEST_STD_VER == 20 -# if defined(__cpp_concepts) && __cpp_concepts >= 201811L +# ifndef _LIBCPP_HAS_NO_CONCEPTS # ifndef __cpp_lib_math_constants # error "__cpp_lib_math_constants should be defined in c++20" # endif @@ -51,13 +51,13 @@ # endif # else # ifdef __cpp_lib_math_constants -# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!" +# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201907L is not defined!" # endif -# endif +# endif // _LIBCPP_HAS_NO_CONCEPTS #elif TEST_STD_VER > 20 -# if defined(__cpp_concepts) && __cpp_concepts >= 201811L +# ifndef _LIBCPP_HAS_NO_CONCEPTS # ifndef __cpp_lib_math_constants # error "__cpp_lib_math_constants should be defined in c++2b" # endif @@ -66,9 +66,9 @@ # endif # else # ifdef __cpp_lib_math_constants -# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!" +# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201907L is not defined!" # endif -# endif +# endif // _LIBCPP_HAS_NO_CONCEPTS #endif // TEST_STD_VER > 20 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 e99b800..d7fabec 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 @@ -2883,7 +2883,7 @@ # error "__cpp_lib_map_try_emplace should have the value 201411L in c++20" # endif -# if defined(__cpp_concepts) && __cpp_concepts >= 201811L +# ifndef _LIBCPP_HAS_NO_CONCEPTS # ifndef __cpp_lib_math_constants # error "__cpp_lib_math_constants should be defined in c++20" # endif @@ -2892,9 +2892,9 @@ # endif # else # ifdef __cpp_lib_math_constants -# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!" +# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201907L is not defined!" # endif -# endif +# endif // _LIBCPP_HAS_NO_CONCEPTS # if !defined(_LIBCPP_VERSION) # ifndef __cpp_lib_math_special_functions @@ -4099,7 +4099,7 @@ # error "__cpp_lib_map_try_emplace should have the value 201411L in c++2b" # endif -# if defined(__cpp_concepts) && __cpp_concepts >= 201811L +# if !_LIBCPP_HAS_NO_CONCEPTS # ifndef __cpp_lib_math_constants # error "__cpp_lib_math_constants should be defined in c++2b" # endif @@ -4108,9 +4108,9 @@ # endif # else # ifdef __cpp_lib_math_constants -# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!" +# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201907L is not defined!" # endif -# endif +# endif // !_LIBCPP_HAS_NO_CONCEPTS # if !defined(_LIBCPP_VERSION) # ifndef __cpp_lib_math_special_functions diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index a7360c3..1544baf 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -422,8 +422,8 @@ feature_test_macros = [ add_version_header(x) for x in [ "name": "__cpp_lib_math_constants", "values": { "c++20": 201907 }, "headers": ["numbers"], - "depends": "defined(__cpp_concepts) && __cpp_concepts >= 201811L", - "internal_depends": "defined(__cpp_concepts) && __cpp_concepts >= 201811L", + "depends": "defined(__cpp_concepts) && __cpp_concepts >= 201907L", + "internal_depends": "defined(__cpp_concepts) && __cpp_concepts >= 201907L", }, { "name": "__cpp_lib_math_special_functions", "values": { "c++17": 201603 }, diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py index 3353f00..e54cece 100644 --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -36,7 +36,7 @@ DEFAULT_FEATURES = [ Feature(name='libcpp-no-if-constexpr', when=lambda cfg: '__cpp_if_constexpr' not in featureTestMacros(cfg)), Feature(name='libcpp-no-structured-bindings', when=lambda cfg: '__cpp_structured_bindings' not in featureTestMacros(cfg)), Feature(name='libcpp-no-deduction-guides', when=lambda cfg: featureTestMacros(cfg).get('__cpp_deduction_guides', 0) < 201611), - Feature(name='libcpp-no-concepts', when=lambda cfg: featureTestMacros(cfg).get('__cpp_concepts', 0) < 201811), + Feature(name='libcpp-no-concepts', when=lambda cfg: featureTestMacros(cfg).get('__cpp_concepts', 0) < 201907), Feature(name='has-fobjc-arc', when=lambda cfg: hasCompileFlag(cfg, '-xobjective-c++ -fobjc-arc') and sys.platform.lower().strip() == 'darwin'), # TODO: this doesn't handle cross-compiling to Apple platforms. Feature(name='objective-c++', when=lambda cfg: hasCompileFlag(cfg, '-xobjective-c++ -fobjc-arc')), -- 2.7.4