[llvm-branch-commits] [libcxx] 4740e92 - [libc++] Improve LIBCXX_ENABLE_INCOMPLETE_FEATURES.

Mark de Wever via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 2 08:31:29 PDT 2021


Author: Mark de Wever
Date: 2021-08-02T17:30:01+02:00
New Revision: 4740e92e29da0916291f0eed2edc75c4b89df5f5

URL: https://github.com/llvm/llvm-project/commit/4740e92e29da0916291f0eed2edc75c4b89df5f5
DIFF: https://github.com/llvm/llvm-project/commit/4740e92e29da0916291f0eed2edc75c4b89df5f5.diff

LOG: [libc++] Improve LIBCXX_ENABLE_INCOMPLETE_FEATURES.

@tcanens pointed out the current behavior of the macro breaks the usage
pattern described in http://wg21.link/SD6
```
```

To support this usage pattern the hard errror is removed. Instead the
header includes nothing but the `<version>` header.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D107134

(cherry picked from commit d618a1cc5c3919d29ee27fa48de80bed4dcb3566)

Added: 
    

Modified: 
    libcxx/include/format
    libcxx/include/ranges

Removed: 
    


################################################################################
diff  --git a/libcxx/include/format b/libcxx/include/format
index 0ec4b85ca0a58..cfd851aa9a3d4 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -55,14 +55,14 @@ namespace std {
 
 */
 
+// Make sure all feature tests macros are always available.
+#include <version>
+// Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
 #include <__config>
 #include <__format/format_error.h>
 #include <__format/format_parse_context.h>
-#include <version>
-
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
-# error "The Format library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -81,4 +81,6 @@ _LIBCPP_END_NAMESPACE_STD
 
 _LIBCPP_POP_MACROS
 
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
 #endif // _LIBCPP_FORMAT

diff  --git a/libcxx/include/ranges b/libcxx/include/ranges
index 47f66fd3f622c..5feaf4c322fcc 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -160,6 +160,11 @@ namespace std::ranges {
 
 */
 
+// Make sure all feature tests macros are always available.
+#include <version>
+// Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
 #include <__config>
 #include <__ranges/access.h>
 #include <__ranges/all.h>
@@ -181,11 +186,6 @@ namespace std::ranges {
 #include <initializer_list> // Required by the standard.
 #include <iterator>         // Required by the standard.
 #include <type_traits>
-#include <version>
-
-#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-# error "The Ranges library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -204,4 +204,6 @@ _LIBCPP_END_NAMESPACE_STD
 
 _LIBCPP_POP_MACROS
 
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
 #endif // _LIBCPP_RANGES


        


More information about the llvm-branch-commits mailing list