[libcxx-commits] [PATCH] D108638: [libc++] Assume that compilers support extended constexpr in C++14 mode

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 24 09:00:03 PDT 2021


ldionne created this revision.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

We don't support any compiler that doesn't support C++14 constexpr when
compiling in C++14 mode anymore, so we can just assume that we have C++14
extended constexpr when compiling in C++14 mode. This allows us to remove
some workarounds for older compilers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108638

Files:
  libcxx/include/__config
  libcxx/test/libcxx/selftest/test_macros.pass.cpp
  libcxx/test/support/test_macros.h


Index: libcxx/test/support/test_macros.h
===================================================================
--- libcxx/test/support/test_macros.h
+++ libcxx/test/support/test_macros.h
@@ -165,7 +165,6 @@
 
 /* Features that were introduced in C++14 */
 #if TEST_STD_VER >= 14
-#define TEST_HAS_EXTENDED_CONSTEXPR
 #define TEST_HAS_VARIABLE_TEMPLATES
 #endif
 
Index: libcxx/test/libcxx/selftest/test_macros.pass.cpp
===================================================================
--- libcxx/test/libcxx/selftest/test_macros.pass.cpp
+++ libcxx/test/libcxx/selftest/test_macros.pass.cpp
@@ -33,16 +33,6 @@
 void test_libcxx_macros()
 {
 //  ===== C++14 features =====
-//  defined(TEST_HAS_EXTENDED_CONSTEXPR)  != defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
-#ifdef TEST_HAS_EXTENDED_CONSTEXPR
-# ifdef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#  error "TEST_EXTENDED_CONSTEXPR mismatch (1)"
-# endif
-#else
-# ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#  error "TEST_EXTENDED_CONSTEXPR mismatch (2)"
-# endif
-#endif
 
 //  defined(TEST_HAS_VARIABLE_TEMPLATES) != defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 #ifdef TEST_HAS_VARIABLE_TEMPLATES
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -492,10 +492,6 @@
 #  define _LIBCPP_HAS_BLOCKS_RUNTIME
 #endif
 
-#if !(__has_feature(cxx_relaxed_constexpr))
-#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#endif
-
 #if !(__has_feature(cxx_variable_templates))
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
@@ -542,11 +538,6 @@
 #  define _LIBCPP_NO_EXCEPTIONS
 #endif
 
-// Determine if GCC supports relaxed constexpr
-#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
-#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#endif
-
 // GCC 5 supports variable templates
 #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
@@ -575,7 +566,6 @@
 #error "MSVC versions prior to Visual Studio 2015 are not supported"
 #endif
 
-#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #define __alignof__ __alignof
 #define _LIBCPP_NORETURN __declspec(noreturn)
@@ -1044,19 +1034,19 @@
 #  define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
 #endif
 
-#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#if _LIBCPP_STD_VER > 11
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
 #else
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX11
 #endif
 
-#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#if _LIBCPP_STD_VER > 14
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
 #else
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX14
 #endif
 
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#if _LIBCPP_STD_VER > 17
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
 #else
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX17
@@ -1096,7 +1086,7 @@
 #  define _LIBCPP_INLINE_VAR
 #endif
 
-#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#if defined(_LIBCPP_DEBUG)
 #   define _LIBCPP_CONSTEXPR_IF_NODEBUG
 #else
 #   define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108638.368363.patch
Type: text/x-patch
Size: 3138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210824/417ac31d/attachment-0001.bin>


More information about the libcxx-commits mailing list