-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[libc++] Bump __cpp_lib_optional
and __cpp_lib_variant
#113650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
frederick-vs-ja
merged 1 commit into
llvm:main
from
frederick-vs-ja:ftm-optional-variant
Oct 25, 2024
Merged
[libc++] Bump __cpp_lib_optional
and __cpp_lib_variant
#113650
frederick-vs-ja
merged 1 commit into
llvm:main
from
frederick-vs-ja:ftm-optional-variant
Oct 25, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In C++20 mode, `__cpp_lib_optional` and `__cpp_lib_variant` should be `202106L` due to DR P2231R1. In C++26 mode, `__cpp_lib_variant` should be bumped to `202306L` due to P2637R3. - Clang 16/17 shouldn't get this bumping, but it's very tricky to make the bumping conditionally enabled. I _hope_ unconditionally bumping in C++26 will be OK for LLVM 20 when the support for Clang 17 is dropped.
@llvm/pr-subscribers-libcxx Author: A. Jiang (frederick-vs-ja) ChangesIn C++20 mode, In C++26 mode,
Related PRs:
Full diff: https://github.com/llvm/llvm-project/pull/113650.diff 8 Files Affected:
diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 05b08da5215350..db24b65caca6c0 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -264,6 +264,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_move_iterator_concept`` ``202207L``
---------------------------------------------------------- -----------------
+ ``__cpp_lib_optional`` ``202106L``
+ ---------------------------------------------------------- -----------------
``__cpp_lib_polymorphic_allocator`` ``201902L``
---------------------------------------------------------- -----------------
``__cpp_lib_ranges`` ``202110L``
@@ -300,6 +302,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_unwrap_ref`` ``201811L``
---------------------------------------------------------- -----------------
+ ``__cpp_lib_variant`` ``202106L``
+ ---------------------------------------------------------- -----------------
**C++23**
----------------------------------------------------------------------------
``__cpp_lib_adaptor_iterator_pair_constructor`` ``202106L``
@@ -491,5 +495,7 @@ Status
``__cpp_lib_to_string`` *unimplemented*
---------------------------------------------------------- -----------------
``__cpp_lib_tuple_like`` *unimplemented*
+ ---------------------------------------------------------- -----------------
+ ``__cpp_lib_variant`` ``202306L``
========================================================== =================
diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index cc75d28f14aac2..9a057be8ad0519 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -192,7 +192,7 @@
"`P2106R0 <https://wg21.link/P2106R0>`__","Alternative wording for GB315 and GB316","2020-02 (Prague)","|Complete|","15.0",""
"`P2116R0 <https://wg21.link/P2116R0>`__","Remove tuple-like protocol support from fixed-extent span","2020-02 (Prague)","|Complete|","11.0",""
"","","","","",""
-"`P2231R1 <https://wg21.link/P2231R1>`__","Missing constexpr in std::optional and std::variant","2021-06 (Virtual)","|Complete|","19.0",""
+"`P2231R1 <https://wg21.link/P2231R1>`__","Missing constexpr in std::optional and std::variant","2021-06 (Virtual)","|Complete|","19.0","Changes of feature-test macros are completed in LLVM 20."
"`P2325R3 <https://wg21.link/P2325R3>`__","Views should not be required to be default constructible","2021-06 (Virtual)","|Complete|","16.0",""
"`P2210R2 <https://wg21.link/P2210R2>`__","Superior String Splitting","2021-06 (Virtual)","|Complete|","16.0",""
"`P2216R3 <https://wg21.link/P2216R3>`__","std::format improvements","2021-06 (Virtual)","|Complete|","15.0",""
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv
index 8864b1ebe28891..d5d5cdda065ae1 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -17,7 +17,7 @@
"`P0792R14 <https://wg21.link/P0792R14>`__","``function_ref``: a type-erased callable reference","2023-06 (Varna)","","",""
"`P2874R2 <https://wg21.link/P2874R2>`__","Mandating Annex D Require No More","2023-06 (Varna)","","",""
"`P2757R3 <https://wg21.link/P2757R3>`__","Type-checking format args","2023-06 (Varna)","","",""
-"`P2637R3 <https://wg21.link/P2637R3>`__","Member ``visit``","2023-06 (Varna)","|Complete|","19.0",""
+"`P2637R3 <https://wg21.link/P2637R3>`__","Member ``visit``","2023-06 (Varna)","|Complete|","19.0","Change of ``__cpp_lib_variant`` is completed in LLVM 20. Change of ``__cpp_lib_format`` is blocked by `P2419R2 <https://wg21.link/P2419R2>`__."
"`P2641R4 <https://wg21.link/P2641R4>`__","Checking if a ``union`` alternative is active","2023-06 (Varna)","","",""
"`P1759R6 <https://wg21.link/P1759R6>`__","Native handles and file streams","2023-06 (Varna)","|Complete|","18.0",""
"`P2697R1 <https://wg21.link/P2697R1>`__","Interfacing ``bitset`` with ``string_view``","2023-06 (Varna)","|Complete|","18.0",""
diff --git a/libcxx/include/version b/libcxx/include/version
index 5ab4f28a04d880..cb75f3b2db681c 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -174,6 +174,7 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque>
__cpp_lib_not_fn 201603L <functional>
__cpp_lib_null_iterators 201304L <iterator>
__cpp_lib_optional 202110L <optional>
+ 202106L // C++20
201606L // C++17
__cpp_lib_optional_range_support 202406L <optional>
__cpp_lib_out_ptr 202311L <memory>
@@ -261,7 +262,9 @@ __cpp_lib_uncaught_exceptions 201411L <exception>
__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>
__cpp_lib_unreachable 202202L <utility>
__cpp_lib_unwrap_ref 201811L <functional>
-__cpp_lib_variant 202102L <variant>
+__cpp_lib_variant 202306L <variant>
+ 202106L // C++20
+ 202102L // C++17
__cpp_lib_void_t 201411L <type_traits>
*/
@@ -427,6 +430,8 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_list_remove_return_type 201806L
# define __cpp_lib_math_constants 201907L
# define __cpp_lib_move_iterator_concept 202207L
+# undef __cpp_lib_optional
+# define __cpp_lib_optional 202106L
# if _LIBCPP_AVAILABILITY_HAS_PMR
# define __cpp_lib_polymorphic_allocator 201902L
# endif
@@ -453,6 +458,8 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_to_array 201907L
# define __cpp_lib_type_identity 201806L
# define __cpp_lib_unwrap_ref 201811L
+# undef __cpp_lib_variant
+# define __cpp_lib_variant 202106L
#endif
#if _LIBCPP_STD_VER >= 23
@@ -570,6 +577,8 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_to_string 202306L
# undef __cpp_lib_tuple_like
// # define __cpp_lib_tuple_like 202311L
+# undef __cpp_lib_variant
+# define __cpp_lib_variant 202306L
#endif
// clang-format on
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
index f265be091f79b5..91abbbc77837bd 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
@@ -19,6 +19,7 @@
__cpp_lib_constrained_equality 202403L [C++26]
__cpp_lib_freestanding_optional 202311L [C++26]
__cpp_lib_optional 201606L [C++17]
+ 202106L [C++20]
202110L [C++23]
__cpp_lib_optional_range_support 202406L [C++26]
*/
@@ -96,8 +97,8 @@
# ifndef __cpp_lib_optional
# error "__cpp_lib_optional should be defined in c++20"
# endif
-# if __cpp_lib_optional != 201606L
-# error "__cpp_lib_optional should have the value 201606L in c++20"
+# if __cpp_lib_optional != 202106L
+# error "__cpp_lib_optional should have the value 202106L in c++20"
# endif
# ifdef __cpp_lib_optional_range_support
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/variant.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/variant.version.compile.pass.cpp
index 4dcc477696bfdd..598e976bda3cf6 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/variant.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/variant.version.compile.pass.cpp
@@ -19,6 +19,8 @@
__cpp_lib_constrained_equality 202403L [C++26]
__cpp_lib_freestanding_variant 202311L [C++26]
__cpp_lib_variant 202102L [C++17]
+ 202106L [C++20]
+ 202306L [C++26]
*/
#include <variant>
@@ -82,8 +84,8 @@
# ifndef __cpp_lib_variant
# error "__cpp_lib_variant should be defined in c++20"
# endif
-# if __cpp_lib_variant != 202102L
-# error "__cpp_lib_variant should have the value 202102L in c++20"
+# if __cpp_lib_variant != 202106L
+# error "__cpp_lib_variant should have the value 202106L in c++20"
# endif
#elif TEST_STD_VER == 23
@@ -99,8 +101,8 @@
# ifndef __cpp_lib_variant
# error "__cpp_lib_variant should be defined in c++23"
# endif
-# if __cpp_lib_variant != 202102L
-# error "__cpp_lib_variant should have the value 202102L in c++23"
+# if __cpp_lib_variant != 202106L
+# error "__cpp_lib_variant should have the value 202106L in c++23"
# endif
#elif TEST_STD_VER > 23
@@ -134,8 +136,8 @@
# ifndef __cpp_lib_variant
# error "__cpp_lib_variant should be defined in c++26"
# endif
-# if __cpp_lib_variant != 202102L
-# error "__cpp_lib_variant should have the value 202102L in c++26"
+# if __cpp_lib_variant != 202306L
+# error "__cpp_lib_variant should have the value 202306L in c++26"
# endif
#endif // TEST_STD_VER > 23
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index 0614f64a2ef04d..5deaee16895f66 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -158,6 +158,7 @@
__cpp_lib_not_fn 201603L [C++17]
__cpp_lib_null_iterators 201304L [C++14]
__cpp_lib_optional 201606L [C++17]
+ 202106L [C++20]
202110L [C++23]
__cpp_lib_optional_range_support 202406L [C++26]
__cpp_lib_out_ptr 202106L [C++23]
@@ -244,6 +245,8 @@
__cpp_lib_unreachable 202202L [C++23]
__cpp_lib_unwrap_ref 201811L [C++20]
__cpp_lib_variant 202102L [C++17]
+ 202106L [C++20]
+ 202306L [C++26]
__cpp_lib_void_t 201411L [C++17]
*/
@@ -4087,8 +4090,8 @@
# ifndef __cpp_lib_optional
# error "__cpp_lib_optional should be defined in c++20"
# endif
-# if __cpp_lib_optional != 201606L
-# error "__cpp_lib_optional should have the value 201606L in c++20"
+# if __cpp_lib_optional != 202106L
+# error "__cpp_lib_optional should have the value 202106L in c++20"
# endif
# ifdef __cpp_lib_optional_range_support
@@ -4569,8 +4572,8 @@
# ifndef __cpp_lib_variant
# error "__cpp_lib_variant should be defined in c++20"
# endif
-# if __cpp_lib_variant != 202102L
-# error "__cpp_lib_variant should have the value 202102L in c++20"
+# if __cpp_lib_variant != 202106L
+# error "__cpp_lib_variant should have the value 202106L in c++20"
# endif
# ifndef __cpp_lib_void_t
@@ -6196,8 +6199,8 @@
# ifndef __cpp_lib_variant
# error "__cpp_lib_variant should be defined in c++23"
# endif
-# if __cpp_lib_variant != 202102L
-# error "__cpp_lib_variant should have the value 202102L in c++23"
+# if __cpp_lib_variant != 202106L
+# error "__cpp_lib_variant should have the value 202106L in c++23"
# endif
# ifndef __cpp_lib_void_t
@@ -8141,8 +8144,8 @@
# ifndef __cpp_lib_variant
# error "__cpp_lib_variant should be defined in c++26"
# endif
-# if __cpp_lib_variant != 202102L
-# error "__cpp_lib_variant should have the value 202102L in c++26"
+# if __cpp_lib_variant != 202306L
+# error "__cpp_lib_variant should have the value 202306L in c++26"
# endif
# ifndef __cpp_lib_void_t
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 7ab1af93d17740..197d6bbc692226 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -942,7 +942,11 @@ def add_version_header(tc):
},
{
"name": "__cpp_lib_optional",
- "values": {"c++17": 201606, "c++23": 202110},
+ "values": {
+ "c++17": 201606,
+ "c++20": 202106, # P2231R1 Missing constexpr in std::optional and std::variant
+ "c++23": 202110, # P0798R8 Monadic operations for std::optional + LWG3621 Remove feature-test macro __cpp_lib_monadic_optional
+ },
"headers": ["optional"],
},
{
@@ -1406,8 +1410,8 @@ def add_version_header(tc):
"name": "__cpp_lib_variant",
"values": {
"c++17": 202102, # std::visit for classes derived from std::variant
- # "c++20": 202106, # Fully constexpr std::variant
- # "c++26": 202306, # Member visit (implemented)
+ "c++20": 202106, # P2231R1 Missing constexpr in std::optional and std::variant
+ "c++26": 202306, # P2637R3 Member visit
},
"headers": ["variant"],
},
|
ldionne
approved these changes
Oct 25, 2024
winner245
pushed a commit
to winner245/llvm-project
that referenced
this pull request
Oct 26, 2024
In C++20 mode, `__cpp_lib_optional` and `__cpp_lib_variant` should be `202106L` due to DR P2231R1. In C++26 mode, `__cpp_lib_variant` should be bumped to `202306L` due to P2637R3. - Clang 16/17 shouldn't get this bumping (as member `visit` requires explicit object parameters), but it's very tricky to make the bumping conditionally enabled. I _hope_ unconditionally bumping in C++26 will be OK for LLVM 20 when the support for Clang 17 is dropped. Related PRs: - https://reviews.llvm.org/D102119 - llvm#83335 - llvm#76447
NoumanAmir657
pushed a commit
to NoumanAmir657/llvm-project
that referenced
this pull request
Nov 4, 2024
In C++20 mode, `__cpp_lib_optional` and `__cpp_lib_variant` should be `202106L` due to DR P2231R1. In C++26 mode, `__cpp_lib_variant` should be bumped to `202306L` due to P2637R3. - Clang 16/17 shouldn't get this bumping (as member `visit` requires explicit object parameters), but it's very tricky to make the bumping conditionally enabled. I _hope_ unconditionally bumping in C++26 will be OK for LLVM 20 when the support for Clang 17 is dropped. Related PRs: - https://reviews.llvm.org/D102119 - llvm#83335 - llvm#76447
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In C++20 mode,
__cpp_lib_optional
and__cpp_lib_variant
should be202106L
due to DR P2231R1.In C++26 mode,
__cpp_lib_variant
should be bumped to202306L
due to P2637R3.visit
requires explicit object parameters), but it's very tricky to make the bumping conditionally enabled. I hope unconditionally bumping in C++26 will be OK for LLVM 20 when the support for Clang 17 is dropped.Related PRs:
constexpr std::variant
. Implement P2231R1 #83335visit
(std::variant
) #76447