[libcxx-commits] [libcxx] b4a13e4 - [libc++] [test] C++14/17-friendly `TEST_IS_CONSTANT_EVALUATED` macro.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 1 12:05:24 PST 2021
Author: Arthur O'Dwyer
Date: 2021-12-01T15:02:54-05:00
New Revision: b4a13e4c9835362b40f87350b2efba3e1eaad2be
URL: https://github.com/llvm/llvm-project/commit/b4a13e4c9835362b40f87350b2efba3e1eaad2be
DIFF: https://github.com/llvm/llvm-project/commit/b4a13e4c9835362b40f87350b2efba3e1eaad2be.diff
LOG: [libc++] [test] C++14/17-friendly `TEST_IS_CONSTANT_EVALUATED` macro.
Reviewed as part of D114658.
Ultimately this will probably have to be flipped around and renamed
`TEST_IS_RUNTIME`, and extended with `TEST_IS_RUNTIME_OR_CXX20` (once
constexpr std::string support is added) and so on for every new C++
version. But we don't need that flexibility yet, so we're not adding it.
Added:
Modified:
libcxx/test/support/test_macros.h
Removed:
################################################################################
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index afc04b2ad6134..a90a52f8ca5d4 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -146,9 +146,11 @@
#endif
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
-# define TEST_IS_CONSTANT_EVALUATED std::is_constant_evaluated()
+# define TEST_IS_CONSTANT_EVALUATED std::is_constant_evaluated()
+#elif __has_builtin(__builtin_is_constant_evaluated)
+# define TEST_IS_CONSTANT_EVALUATED __builtin_is_constant_evaluated()
#else
-# define TEST_IS_CONSTANT_EVALUATED false
+# define TEST_IS_CONSTANT_EVALUATED false
#endif
#if TEST_STD_VER >= 14
More information about the libcxx-commits
mailing list