[libcxx-commits] [libcxx] e4dd614 - [libcxx] cleans up __cpp_concepts mess
Christopher Di Bella via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Feb 26 10:44:09 PST 2021
Author: Christopher Di Bella
Date: 2021-02-26T18:43:40Z
New Revision: e4dd614ae81194b0a50361a91f8bd4364916ef2e
URL: https://github.com/llvm/llvm-project/commit/e4dd614ae81194b0a50361a91f8bd4364916ef2e
DIFF: https://github.com/llvm/llvm-project/commit/e4dd614ae81194b0a50361a91f8bd4364916ef2e.diff
LOG: [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
Added:
Modified:
libcxx/include/concepts
libcxx/include/numbers
libcxx/include/random
libcxx/include/version
libcxx/test/std/language.support/support.limits/support.limits.general/numbers.version.pass.cpp
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp
libcxx/utils/generate_feature_test_macro_components.py
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/include/concepts b/libcxx/include/concepts
index dac6b694baf5..3d57c401d4ea 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<class _Fn, class... _Args>
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 38dad9955487..e5172af9f544 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 <concepts>
#include <type_traits>
#include <version>
@@ -99,22 +100,19 @@ template <class T> inline constexpr T inv_sqrt3_v = __illformed<T>{};
template <class T> inline constexpr T egamma_v = __illformed<T>{};
template <class T> inline constexpr T phi_v = __illformed<T>{};
-template <class T>
-concept __floating_point = is_floating_point_v<T>;
-
-template <__floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;
-template <__floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;
-template <__floating_point T> inline constexpr T log10e_v<T> = 0.434294481903251827651128918916605;
-template <__floating_point T> inline constexpr T pi_v<T> = 3.141592653589793238462643383279502;
-template <__floating_point T> inline constexpr T inv_pi_v<T> = 0.318309886183790671537767526745028;
-template <__floating_point T> inline constexpr T inv_sqrtpi_v<T> = 0.564189583547756286948079451560772;
-template <__floating_point T> inline constexpr T ln2_v<T> = 0.693147180559945309417232121458176;
-template <__floating_point T> inline constexpr T ln10_v<T> = 2.302585092994045684017991454684364;
-template <__floating_point T> inline constexpr T sqrt2_v<T> = 1.414213562373095048801688724209698;
-template <__floating_point T> inline constexpr T sqrt3_v<T> = 1.732050807568877293527446341505872;
-template <__floating_point T> inline constexpr T inv_sqrt3_v<T> = 0.577350269189625764509148780501957;
-template <__floating_point T> inline constexpr T egamma_v<T> = 0.577215664901532860606512090082402;
-template <__floating_point T> inline constexpr T phi_v<T> = 1.618033988749894848204586834365638;
+template <floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;
+template <floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;
+template <floating_point T> inline constexpr T log10e_v<T> = 0.434294481903251827651128918916605;
+template <floating_point T> inline constexpr T pi_v<T> = 3.141592653589793238462643383279502;
+template <floating_point T> inline constexpr T inv_pi_v<T> = 0.318309886183790671537767526745028;
+template <floating_point T> inline constexpr T inv_sqrtpi_v<T> = 0.564189583547756286948079451560772;
+template <floating_point T> inline constexpr T ln2_v<T> = 0.693147180559945309417232121458176;
+template <floating_point T> inline constexpr T ln10_v<T> = 2.302585092994045684017991454684364;
+template <floating_point T> inline constexpr T sqrt2_v<T> = 1.414213562373095048801688724209698;
+template <floating_point T> inline constexpr T sqrt3_v<T> = 1.732050807568877293527446341505872;
+template <floating_point T> inline constexpr T inv_sqrt3_v<T> = 0.577350269189625764509148780501957;
+template <floating_point T> inline constexpr T egamma_v<T> = 0.577215664901532860606512090082402;
+template <floating_point T> inline constexpr T phi_v<T> = 1.618033988749894848204586834365638;
inline constexpr double e = e_v<double>;
inline constexpr double log2e = log2e_v<double>;
@@ -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 1cbe9b577f0b..a2f45ba7ea42 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<class _Gen>
@@ -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 3252219a7fd3..e8697232bac5 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -336,7 +336,7 @@ __cpp_lib_void_t 201411L <type_traits>
# 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 9e6b1fa86540..aaa64d1f7feb 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 e99b800e5ceb..d7fabec6c1b0 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 a7360c37e8be..1544baf737c7 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -422,8 +422,8 @@ def add_version_header(tc):
"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 3353f00faf35..e54cecef0ab8 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -36,7 +36,7 @@
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')),
More information about the libcxx-commits
mailing list