-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[libc++][C++03] Use __cxx03/
headers in C++03 mode
#109002
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
@llvm/pr-subscribers-libcxx @llvm/pr-subscribers-github-workflow Author: Nikolas Klauser (philnik777) ChangesPatch is 902.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/109002.diff 131 Files Affected:
diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index b5e60781e00064..421f2d5f22d2f4 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -55,6 +55,7 @@ jobs:
fail-fast: false
matrix:
config: [
+ 'cxx03-main-headers',
'generic-cxx03',
'generic-cxx26',
'generic-modules'
diff --git a/libcxx/cmake/caches/cxx03-main-headers.cmake b/libcxx/cmake/caches/cxx03-main-headers.cmake
new file mode 100644
index 00000000000000..70d6f1814fb58d
--- /dev/null
+++ b/libcxx/cmake/caches/cxx03-main-headers.cmake
@@ -0,0 +1,2 @@
+set(LIBCXX_TEST_PARAMS "std=c++03;test-main-headers=True" CACHE STRING "")
+set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
diff --git a/libcxx/include/__config b/libcxx/include/__config
index ff5e3cf5faf0e0..51e8ec2388f4c4 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -14,6 +14,7 @@
#include <__configuration/abi.h>
#include <__configuration/availability.h>
#include <__configuration/compiler.h>
+#include <__configuration/cxx03.h>
#include <__configuration/platform.h>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
diff --git a/libcxx/include/__configuration/cxx03.h b/libcxx/include/__configuration/cxx03.h
new file mode 100644
index 00000000000000..606de3d2c735f0
--- /dev/null
+++ b/libcxx/include/__configuration/cxx03.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CONFIGURATION_CXX03_H
+#define _LIBCPP___CONFIGURATION_CXX03_H
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+# pragma GCC system_header
+#endif
+
+// NOLINTNEXTLINE(libcpp-cpp-version-check)
+# if __cplusplus < 201103L
+# define _LIBCPP_CXX03_LANG
+# endif
+
+#endif // _LIBCPP___CONFIGURATION_CXX03_H
diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config
index 935fa4cc404f4e..965ac4f1e6ffff 100644
--- a/libcxx/include/__cxx03/__config
+++ b/libcxx/include/__cxx03/__config
@@ -157,11 +157,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
# define _LIBCPP_TOSTRING2(x) #x
# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
-// NOLINTNEXTLINE(libcpp-cpp-version-check)
-# if __cplusplus < 201103L
-# define _LIBCPP_CXX03_LANG
-# endif
-
# ifndef __has_constexpr_builtin
# define __has_constexpr_builtin(x) 0
# endif
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 36fd035b7e51b3..e26d8241e683f6 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -1827,232 +1827,238 @@ template <class BidirectionalIterator, class Compare>
*/
-#include <__config>
-
-#include <__algorithm/adjacent_find.h>
-#include <__algorithm/all_of.h>
-#include <__algorithm/any_of.h>
-#include <__algorithm/binary_search.h>
-#include <__algorithm/copy.h>
-#include <__algorithm/copy_backward.h>
-#include <__algorithm/copy_if.h>
-#include <__algorithm/copy_n.h>
-#include <__algorithm/count.h>
-#include <__algorithm/count_if.h>
-#include <__algorithm/equal.h>
-#include <__algorithm/equal_range.h>
-#include <__algorithm/fill.h>
-#include <__algorithm/fill_n.h>
-#include <__algorithm/find.h>
-#include <__algorithm/find_end.h>
-#include <__algorithm/find_first_of.h>
-#include <__algorithm/find_if.h>
-#include <__algorithm/find_if_not.h>
-#include <__algorithm/for_each.h>
-#include <__algorithm/generate.h>
-#include <__algorithm/generate_n.h>
-#include <__algorithm/includes.h>
-#include <__algorithm/inplace_merge.h>
-#include <__algorithm/is_heap.h>
-#include <__algorithm/is_heap_until.h>
-#include <__algorithm/is_partitioned.h>
-#include <__algorithm/is_permutation.h>
-#include <__algorithm/is_sorted.h>
-#include <__algorithm/is_sorted_until.h>
-#include <__algorithm/iter_swap.h>
-#include <__algorithm/lexicographical_compare.h>
-#include <__algorithm/lower_bound.h>
-#include <__algorithm/make_heap.h>
-#include <__algorithm/max.h>
-#include <__algorithm/max_element.h>
-#include <__algorithm/merge.h>
-#include <__algorithm/min.h>
-#include <__algorithm/min_element.h>
-#include <__algorithm/minmax.h>
-#include <__algorithm/minmax_element.h>
-#include <__algorithm/mismatch.h>
-#include <__algorithm/move.h>
-#include <__algorithm/move_backward.h>
-#include <__algorithm/next_permutation.h>
-#include <__algorithm/none_of.h>
-#include <__algorithm/nth_element.h>
-#include <__algorithm/partial_sort.h>
-#include <__algorithm/partial_sort_copy.h>
-#include <__algorithm/partition.h>
-#include <__algorithm/partition_copy.h>
-#include <__algorithm/partition_point.h>
-#include <__algorithm/pop_heap.h>
-#include <__algorithm/prev_permutation.h>
-#include <__algorithm/push_heap.h>
-#include <__algorithm/remove.h>
-#include <__algorithm/remove_copy.h>
-#include <__algorithm/remove_copy_if.h>
-#include <__algorithm/remove_if.h>
-#include <__algorithm/replace.h>
-#include <__algorithm/replace_copy.h>
-#include <__algorithm/replace_copy_if.h>
-#include <__algorithm/replace_if.h>
-#include <__algorithm/reverse.h>
-#include <__algorithm/reverse_copy.h>
-#include <__algorithm/rotate.h>
-#include <__algorithm/rotate_copy.h>
-#include <__algorithm/search.h>
-#include <__algorithm/search_n.h>
-#include <__algorithm/set_difference.h>
-#include <__algorithm/set_intersection.h>
-#include <__algorithm/set_symmetric_difference.h>
-#include <__algorithm/set_union.h>
-#include <__algorithm/shuffle.h>
-#include <__algorithm/sort.h>
-#include <__algorithm/sort_heap.h>
-#include <__algorithm/stable_partition.h>
-#include <__algorithm/stable_sort.h>
-#include <__algorithm/swap_ranges.h>
-#include <__algorithm/transform.h>
-#include <__algorithm/unique.h>
-#include <__algorithm/unique_copy.h>
-#include <__algorithm/upper_bound.h>
-
-#if _LIBCPP_STD_VER >= 17
-# include <__algorithm/clamp.h>
-# include <__algorithm/for_each_n.h>
-# include <__algorithm/pstl.h>
-# include <__algorithm/sample.h>
-#endif // _LIBCPP_STD_VER >= 17
-
-#if _LIBCPP_STD_VER >= 20
-# include <__algorithm/in_found_result.h>
-# include <__algorithm/in_fun_result.h>
-# include <__algorithm/in_in_out_result.h>
-# include <__algorithm/in_in_result.h>
-# include <__algorithm/in_out_out_result.h>
-# include <__algorithm/in_out_result.h>
-# include <__algorithm/lexicographical_compare_three_way.h>
-# include <__algorithm/min_max_result.h>
-# include <__algorithm/ranges_adjacent_find.h>
-# include <__algorithm/ranges_all_of.h>
-# include <__algorithm/ranges_any_of.h>
-# include <__algorithm/ranges_binary_search.h>
-# include <__algorithm/ranges_clamp.h>
-# include <__algorithm/ranges_contains.h>
-# include <__algorithm/ranges_copy.h>
-# include <__algorithm/ranges_copy_backward.h>
-# include <__algorithm/ranges_copy_if.h>
-# include <__algorithm/ranges_copy_n.h>
-# include <__algorithm/ranges_count.h>
-# include <__algorithm/ranges_count_if.h>
-# include <__algorithm/ranges_equal.h>
-# include <__algorithm/ranges_equal_range.h>
-# include <__algorithm/ranges_fill.h>
-# include <__algorithm/ranges_fill_n.h>
-# include <__algorithm/ranges_find.h>
-# include <__algorithm/ranges_find_end.h>
-# include <__algorithm/ranges_find_first_of.h>
-# include <__algorithm/ranges_find_if.h>
-# include <__algorithm/ranges_find_if_not.h>
-# include <__algorithm/ranges_for_each.h>
-# include <__algorithm/ranges_for_each_n.h>
-# include <__algorithm/ranges_generate.h>
-# include <__algorithm/ranges_generate_n.h>
-# include <__algorithm/ranges_includes.h>
-# include <__algorithm/ranges_inplace_merge.h>
-# include <__algorithm/ranges_is_heap.h>
-# include <__algorithm/ranges_is_heap_until.h>
-# include <__algorithm/ranges_is_partitioned.h>
-# include <__algorithm/ranges_is_permutation.h>
-# include <__algorithm/ranges_is_sorted.h>
-# include <__algorithm/ranges_is_sorted_until.h>
-# include <__algorithm/ranges_lexicographical_compare.h>
-# include <__algorithm/ranges_lower_bound.h>
-# include <__algorithm/ranges_make_heap.h>
-# include <__algorithm/ranges_max.h>
-# include <__algorithm/ranges_max_element.h>
-# include <__algorithm/ranges_merge.h>
-# include <__algorithm/ranges_min.h>
-# include <__algorithm/ranges_min_element.h>
-# include <__algorithm/ranges_minmax.h>
-# include <__algorithm/ranges_minmax_element.h>
-# include <__algorithm/ranges_mismatch.h>
-# include <__algorithm/ranges_move.h>
-# include <__algorithm/ranges_move_backward.h>
-# include <__algorithm/ranges_next_permutation.h>
-# include <__algorithm/ranges_none_of.h>
-# include <__algorithm/ranges_nth_element.h>
-# include <__algorithm/ranges_partial_sort.h>
-# include <__algorithm/ranges_partial_sort_copy.h>
-# include <__algorithm/ranges_partition.h>
-# include <__algorithm/ranges_partition_copy.h>
-# include <__algorithm/ranges_partition_point.h>
-# include <__algorithm/ranges_pop_heap.h>
-# include <__algorithm/ranges_prev_permutation.h>
-# include <__algorithm/ranges_push_heap.h>
-# include <__algorithm/ranges_remove.h>
-# include <__algorithm/ranges_remove_copy.h>
-# include <__algorithm/ranges_remove_copy_if.h>
-# include <__algorithm/ranges_remove_if.h>
-# include <__algorithm/ranges_replace.h>
-# include <__algorithm/ranges_replace_copy.h>
-# include <__algorithm/ranges_replace_copy_if.h>
-# include <__algorithm/ranges_replace_if.h>
-# include <__algorithm/ranges_reverse.h>
-# include <__algorithm/ranges_reverse_copy.h>
-# include <__algorithm/ranges_rotate.h>
-# include <__algorithm/ranges_rotate_copy.h>
-# include <__algorithm/ranges_sample.h>
-# include <__algorithm/ranges_search.h>
-# include <__algorithm/ranges_search_n.h>
-# include <__algorithm/ranges_set_difference.h>
-# include <__algorithm/ranges_set_intersection.h>
-# include <__algorithm/ranges_set_symmetric_difference.h>
-# include <__algorithm/ranges_set_union.h>
-# include <__algorithm/ranges_shuffle.h>
-# include <__algorithm/ranges_sort.h>
-# include <__algorithm/ranges_sort_heap.h>
-# include <__algorithm/ranges_stable_partition.h>
-# include <__algorithm/ranges_stable_sort.h>
-# include <__algorithm/ranges_swap_ranges.h>
-# include <__algorithm/ranges_transform.h>
-# include <__algorithm/ranges_unique.h>
-# include <__algorithm/ranges_unique_copy.h>
-# include <__algorithm/ranges_upper_bound.h>
-# include <__algorithm/shift_left.h>
-# include <__algorithm/shift_right.h>
-#endif
-
-#if _LIBCPP_STD_VER >= 23
-# include <__algorithm/fold.h>
-# include <__algorithm/ranges_contains_subrange.h>
-# include <__algorithm/ranges_ends_with.h>
-# include <__algorithm/ranges_find_last.h>
-# include <__algorithm/ranges_starts_with.h>
-#endif // _LIBCPP_STD_VER >= 23
-
-#include <version>
+#include <__configuration/cxx03.h>
+
+#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_CXX03_USE_MAIN_HEADERS)
+# include <__cxx03/algorithm>
+#else
+# include <__config>
+
+# include <__algorithm/adjacent_find.h>
+# include <__algorithm/all_of.h>
+# include <__algorithm/any_of.h>
+# include <__algorithm/binary_search.h>
+# include <__algorithm/copy.h>
+# include <__algorithm/copy_backward.h>
+# include <__algorithm/copy_if.h>
+# include <__algorithm/copy_n.h>
+# include <__algorithm/count.h>
+# include <__algorithm/count_if.h>
+# include <__algorithm/equal.h>
+# include <__algorithm/equal_range.h>
+# include <__algorithm/fill.h>
+# include <__algorithm/fill_n.h>
+# include <__algorithm/find.h>
+# include <__algorithm/find_end.h>
+# include <__algorithm/find_first_of.h>
+# include <__algorithm/find_if.h>
+# include <__algorithm/find_if_not.h>
+# include <__algorithm/for_each.h>
+# include <__algorithm/generate.h>
+# include <__algorithm/generate_n.h>
+# include <__algorithm/includes.h>
+# include <__algorithm/inplace_merge.h>
+# include <__algorithm/is_heap.h>
+# include <__algorithm/is_heap_until.h>
+# include <__algorithm/is_partitioned.h>
+# include <__algorithm/is_permutation.h>
+# include <__algorithm/is_sorted.h>
+# include <__algorithm/is_sorted_until.h>
+# include <__algorithm/iter_swap.h>
+# include <__algorithm/lexicographical_compare.h>
+# include <__algorithm/lower_bound.h>
+# include <__algorithm/make_heap.h>
+# include <__algorithm/max.h>
+# include <__algorithm/max_element.h>
+# include <__algorithm/merge.h>
+# include <__algorithm/min.h>
+# include <__algorithm/min_element.h>
+# include <__algorithm/minmax.h>
+# include <__algorithm/minmax_element.h>
+# include <__algorithm/mismatch.h>
+# include <__algorithm/move.h>
+# include <__algorithm/move_backward.h>
+# include <__algorithm/next_permutation.h>
+# include <__algorithm/none_of.h>
+# include <__algorithm/nth_element.h>
+# include <__algorithm/partial_sort.h>
+# include <__algorithm/partial_sort_copy.h>
+# include <__algorithm/partition.h>
+# include <__algorithm/partition_copy.h>
+# include <__algorithm/partition_point.h>
+# include <__algorithm/pop_heap.h>
+# include <__algorithm/prev_permutation.h>
+# include <__algorithm/push_heap.h>
+# include <__algorithm/remove.h>
+# include <__algorithm/remove_copy.h>
+# include <__algorithm/remove_copy_if.h>
+# include <__algorithm/remove_if.h>
+# include <__algorithm/replace.h>
+# include <__algorithm/replace_copy.h>
+# include <__algorithm/replace_copy_if.h>
+# include <__algorithm/replace_if.h>
+# include <__algorithm/reverse.h>
+# include <__algorithm/reverse_copy.h>
+# include <__algorithm/rotate.h>
+# include <__algorithm/rotate_copy.h>
+# include <__algorithm/search.h>
+# include <__algorithm/search_n.h>
+# include <__algorithm/set_difference.h>
+# include <__algorithm/set_intersection.h>
+# include <__algorithm/set_symmetric_difference.h>
+# include <__algorithm/set_union.h>
+# include <__algorithm/shuffle.h>
+# include <__algorithm/sort.h>
+# include <__algorithm/sort_heap.h>
+# include <__algorithm/stable_partition.h>
+# include <__algorithm/stable_sort.h>
+# include <__algorithm/swap_ranges.h>
+# include <__algorithm/transform.h>
+# include <__algorithm/unique.h>
+# include <__algorithm/unique_copy.h>
+# include <__algorithm/upper_bound.h>
+
+# if _LIBCPP_STD_VER >= 17
+# include <__algorithm/clamp.h>
+# include <__algorithm/for_each_n.h>
+# include <__algorithm/pstl.h>
+# include <__algorithm/sample.h>
+# endif // _LIBCPP_STD_VER >= 17
+
+# if _LIBCPP_STD_VER >= 20
+# include <__algorithm/in_found_result.h>
+# include <__algorithm/in_fun_result.h>
+# include <__algorithm/in_in_out_result.h>
+# include <__algorithm/in_in_result.h>
+# include <__algorithm/in_out_out_result.h>
+# include <__algorithm/in_out_result.h>
+# include <__algorithm/lexicographical_compare_three_way.h>
+# include <__algorithm/min_max_result.h>
+# include <__algorithm/ranges_adjacent_find.h>
+# include <__algorithm/ranges_all_of.h>
+# include <__algorithm/ranges_any_of.h>
+# include <__algorithm/ranges_binary_search.h>
+# include <__algorithm/ranges_clamp.h>
+# include <__algorithm/ranges_contains.h>
+# include <__algorithm/ranges_copy.h>
+# include <__algorithm/ranges_copy_backward.h>
+# include <__algorithm/ranges_copy_if.h>
+# include <__algorithm/ranges_copy_n.h>
+# include <__algorithm/ranges_count.h>
+# include <__algorithm/ranges_count_if.h>
+# include <__algorithm/ranges_equal.h>
+# include <__algorithm/ranges_equal_range.h>
+# include <__algorithm/ranges_fill.h>
+# include <__algorithm/ranges_fill_n.h>
+# include <__algorithm/ranges_find.h>
+# include <__algorithm/ranges_find_end.h>
+# include <__algorithm/ranges_find_first_of.h>
+# include <__algorithm/ranges_find_if.h>
+# include <__algorithm/ranges_find_if_not.h>
+# include <__algorithm/ranges_for_each.h>
+# include <__algorithm/ranges_for_each_n.h>
+# include <__algorithm/ranges_generate.h>
+# include <__algorithm/ranges_generate_n.h>
+# include <__algorithm/ranges_includes.h>
+# include <__algorithm/ranges_inplace_merge.h>
+# include <__algorithm/ranges_is_heap.h>
+# include <__algorithm/ranges_is_heap_until.h>
+# include <__algorithm/ranges_is_partitioned.h>
+# include <__algorithm/ranges_is_permutation.h>
+# include <__algorithm/ranges_is_sorted.h>
+# include <__algorithm/ranges_is_sorted_until.h>
+# include <__algorithm/ranges_lexicographical_compare.h>
+# include <__algorithm/ranges_lower_bound.h>
+# include <__algorithm/ranges_make_heap.h>
+# include <__algorithm/ranges_max.h>
+# include <__algorithm/ranges_max_element.h>
+# include <__algorithm/ranges_merge.h>
+# include <__algorithm/ranges_min.h>
+# include <__algorithm/ranges_min_element.h>
+# include <__algorithm/ranges_minmax.h>
+# include <__algorithm/ranges_minmax_element.h>
+# include <__algorithm/ranges_mismatch.h>
+# include <__algorithm/ranges_move.h>
+# include <__algorithm/ranges_move_backward.h>
+# include <__algorithm/ranges_next_permutation.h>
+# include <__algorithm/ranges_none_of.h>
+# include <__algorithm/ranges_nth_element.h>
+# include <__algorithm/ranges_partial_sort.h>
+# include <__algorithm/ranges_partial_sort_copy.h>
+# include <__algorithm/ranges_partition.h>
+# include <__algorithm/ranges_partition_copy.h>
+# include <__algorithm/ranges_partition_point.h>
+# include <__algorithm/ranges_pop_heap.h>
+# include <__algorithm/ranges_prev_permutation.h>
+# include <__algorithm/ranges_push_heap.h>
+# include <__algorithm/ranges_remove.h>
+# include <__algorithm/ranges_remove_copy.h>
+# include <__algorithm/ranges_remove_copy_if.h>
+# include <__algorithm/ranges_remove_if.h>
+# include <__algorithm/ranges_replace.h>
+# include <__algorithm/ranges_replace_copy.h>
+# include <__algorithm/ranges_replace_copy_if.h>
+# include <__algorithm/ranges_replace_if.h>
+# include <__algorithm/ranges_reverse.h>
+# include <__algorithm/ranges_reverse_copy.h>
+# include <__algorithm/ranges_rotate.h>
+# include <__algorithm/ranges_rotate_copy.h>
+# include <__algorithm/ranges_sample.h>
+# include <__algorithm/ranges_search.h>
+# include <__algorithm/ranges_search_n.h>
+# include <__algorithm/ranges_set_difference.h>
+# include <__algorithm/ranges_set_intersection.h>
+# include <__algorithm/ranges_set_symmetric_difference.h>
+# include <__algorithm/ranges_set_union.h>
+# include <__algorithm/ranges_shuffle.h>
+# include <__algorithm/ranges_sort.h>
+# include <__algorithm/ranges_sort_heap.h>
+# include <__algorithm/ranges_stable_partition.h>
+# include <__algorithm/ranges_stable_sort.h>
+# include <__algorithm/ranges_swap_ranges.h>
+# include <__algorithm/ranges_transform.h>
+# include <__algorithm/ranges_unique.h>
+# include <__algorithm/ranges_unique_copy.h>
+# include <__algorithm/ranges_upper_bound.h>
+# include <__algorithm/shift_left.h>
+# include <__algorithm/shift_right.h>
+# endif
+
+# if _LIBCPP_STD_VER >= 23
+# include <__algorithm/fold.h>
+# include <__algorithm/ranges_contains_subrange.h>
+# include <__algorithm/ranges_ends_with.h>
+# include <__algorithm/ranges_find_last.h>
+# include <__algorithm/ranges_starts_with.h>
+# endif // _LIBCPP_STD_VER >= 23
+
+# include <version>
// standard-mandated includes
// [algorithm.syn]
-#include <initializer_list>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14
-# include <execution>
-#endif
-
-#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
-# include <atomic>
-# include <bit>
-# include <concepts>
-# include <cstdlib>
-# include <cstring>
-# include <iterator>
-# include <memory>
-# include <stdexcept>
-# include <type_traits>
-# include <utility>
-#endif
+# include <initializer_list>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
+
+# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14
+# include <execution>
+# endif
+
+# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBC...
[truncated]
|
@philnik777 These changes seem significant enough to affect already opened PRs and to confuse the authors who are unaware of the changes. So basically you are surrounding all C++11 mode headers with: #include <__configuration/cxx03.h>
#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_CXX03_USE_MAIN_HEADERS)
# include <__cxx03/any>
#else
...
#endif // _LIBCPP_CXX03_LANG And these should be added even to headers not available in C++03 mode, right? Is there anything else that needs to be observed/implemented in new PRs? |
@Zingam currently you can just continue your PRs without any changes. I'll take up any slack. Right now I guard non-C++03 header to make the changes as mechanical as possible. Some of this will be reverted in later PRs. |
e888ef3
to
df30222
Compare
4d02649
to
d7127f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense, however I would like you to post this PR to the RFC, since we mentioned back then that the decision of Driver vs conditional includes would be best taken based on actual proposed changes. This will give this patch a bit more visibility and we can ensure that we have consensus on moving forward with this implementation strategy.
df30222
to
34d0b52
Compare
d7127f0
to
f6850b2
Compare
34d0b52
to
83f8c8d
Compare
f6850b2
to
700c9c0
Compare
83f8c8d
to
bf624c9
Compare
700c9c0
to
055ae1f
Compare
bf624c9
to
bea0f2b
Compare
6c1746f
to
b128fbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's write down the order for landing this in smaller pieces:
- Land the
#if 0
change which addresses the formatting issues. - Land the CMake changes that start installing the C++03 headers.
- Switch to
#if __cplusplus < C++11 && USE_FROZEN_HEADERS
(or whatever), and also add the CI with XFAILs. If there are too many XFAILs, the CI bit should probably be left to a separate patch.
We can treat even C++23-only headers the same for now, by including __cxx03/__config
in them. That's the status quo and we should start with that. However, as a follow-up, we should go through all of the >= 11 headers and make them "not care" about the C++03 frozen headers. We could in addition perhaps diagnose the use of -std=c++03
in the normal __config
file with an error.
b128fbe
to
5ea3719
Compare
2696de4
to
9497276
Compare
9497276
to
6c87855
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to record the discussion we just had about this patch.
As we make more progress on this project, we discover additional complexity that we need to handle. This was expected, however we didn't know what we were going to find. Anything that falls in the intersection of the C++03 headers and the new headers is where things can be difficult, such as:
- The configuration of the library via CMake (embodied by
__config_site
) - The dylib, which must be shared by both sets of headers
This patch makes it clear that handling the configuration side of things is non-trivial and can lead to very confusing situations. For example, we need to shim the __config_site
header to account for changes from #if defined(_LIBCPP_FOO)
to #if _LIBCPP_FOO
in the past couple of months. IMO that's extremely confusing and not a state that we can live with for a prolonged period of time, since it'll lead to bugs. The same goes for e.g. the __locale_base_api
refactoring where we are changing some symbol names on Windows. Those are changes we'd need to backport to the C++03 headers in order for the codebase to stay maintainable.
We discussed another approach where we instead fork individual headers as we decide that we want to drop C++03 headers. For example, create __cxx03/vector
only when we actually want to fork its implementation to take advantage of non-03 features. Seeing all the complexity introduced by the approach pursued here, that's the approach I would like for us to try instead. @philnik777 disagrees and thinks we'll end up in a similar place at the end of the day (I'm not sure I agree but that's a reasonable opinion to have).
Since the approach taken in this patch is still something we can back out of, I am okay with moving forward with it experimentally despite having significant concerns. If we don't manage to simplify the intersection between the old and the new headers, I don't think this is something we can ever ship. But if we do, then perhaps this approach is fine in the end. Since the only way to know for sure is to keep making progress on this approach, I'm fine with moving forward with this.
The subsequent patches should aim to simplify the old/new headers integration and those can be iterated upon in a separate branch without introducing too much risk for merge conflicts.
I'd like to see this again with comments resolved before this gets merged.
I feel a bit bad for being so critical of this approach, but I think it was unavoidable that we'd find out difficulties with any approach trying to do this non-trivial change. We'll have to figure out whether these difficulties can be overcome or if they actually outweigh the benefits provided by the split.
6c87855
to
0e188c0
Compare
You can test this locally with the following command:git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 8dc23efbe6c584c06d6472c6f1b679b5ca861b07 82a12894ed58c0420c7b92eda4d2487f1f4e3b99 libcxx/include/__cxx03/__configuration/config_site_shim.h libcxx/include/__cxx03/__configuration/abi.h libcxx/include/__cxx03/__configuration/compiler.h libcxx/include/__cxx03/__configuration/language.h libcxx/include/__cxx03/__configuration/platform.h libcxx/include/__cxx03/__locale_dir/locale_base_api/bsd_locale_fallbacks.h libcxx/include/__cxx03/__thread/support/pthread.h libcxx/include/complex.h libcxx/include/ctype.h libcxx/include/errno.h libcxx/include/fenv.h libcxx/include/float.h libcxx/include/inttypes.h libcxx/include/math.h libcxx/include/stdatomic.h libcxx/include/stdbool.h libcxx/include/stddef.h libcxx/include/stdio.h libcxx/include/stdlib.h libcxx/include/string.h libcxx/include/tgmath.h libcxx/include/uchar.h libcxx/include/wchar.h libcxx/include/wctype.h libcxx/test/libcxx/algorithms/half_positive.pass.cpp libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp libcxx/test/libcxx/assertions/modes/none.pass.cpp libcxx/test/libcxx/assertions/single_expression.pass.cpp libcxx/test/libcxx/atomics/atomics.syn/compatible_with_stdatomic.compile.pass.cpp libcxx/test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp libcxx/test/libcxx/containers/associative/tree_key_value_traits.pass.cpp libcxx/test/libcxx/containers/associative/tree_left_rotate.pass.cpp libcxx/test/libcxx/containers/associative/tree_remove.pass.cpp libcxx/test/libcxx/containers/associative/tree_right_rotate.pass.cpp libcxx/test/libcxx/containers/associative/unord.map/abi.compile.pass.cpp libcxx/test/libcxx/containers/associative/unord.set/abi.compile.pass.cpp libcxx/test/libcxx/containers/container_traits.compile.pass.cpp libcxx/test/libcxx/containers/unord/key_value_traits.pass.cpp libcxx/test/libcxx/containers/unord/next_pow2.pass.cpp libcxx/test/libcxx/containers/unord/next_prime.pass.cpp libcxx/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp libcxx/test/libcxx/input.output/file.streams/fstreams/filebuf/traits_mismatch.verify.cpp libcxx/test/libcxx/input.output/file.streams/fstreams/traits_mismatch.verify.cpp libcxx/test/libcxx/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp libcxx/test/libcxx/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp libcxx/test/libcxx/input.output/string.streams/stringbuf/const_sso_buffer.pass.cpp libcxx/test/libcxx/input.output/string.streams/traits_mismatch.verify.cpp libcxx/test/libcxx/iterators/aliasing_iterator.pass.cpp libcxx/test/libcxx/iterators/bounded_iter/arithmetic.pass.cpp libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp libcxx/test/libcxx/iterators/bounded_iter/pointer_traits.pass.cpp libcxx/test/libcxx/iterators/bounded_iter/types.compile.pass.cpp libcxx/test/libcxx/iterators/contiguous_iterators.conv.compile.pass.cpp libcxx/test/libcxx/iterators/contiguous_iterators.verify.cpp libcxx/test/libcxx/iterators/iterator.primitives/iterator.operations/prev.verify.cpp libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp libcxx/test/libcxx/memory/allocation_guard.pass.cpp libcxx/test/libcxx/memory/swap_allocator.pass.cpp libcxx/test/libcxx/numerics/bit.ops.pass.cpp libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp libcxx/test/libcxx/numerics/complex.number/cmplx.over.pow.pass.cpp libcxx/test/libcxx/selftest/test_macros.pass.cpp libcxx/test/libcxx/strings/c.strings/constexpr_memmove.pass.cpp libcxx/test/libcxx/type_traits/datasizeof.compile.pass.cpp libcxx/test/libcxx/type_traits/is_constant_evaluated.pass.cpp libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp libcxx/test/libcxx/utilities/exception_guard.odr.sh.cpp libcxx/test/libcxx/utilities/is_pointer_in_range.pass.cpp libcxx/test/libcxx/utilities/is_valid_range.pass.cpp libcxx/test/libcxx/utilities/meta/meta_base.pass.cpp libcxx/test/libcxx/utilities/no_destroy.pass.cpp libcxx/test/libcxx/utilities/template.bitset/includes.pass.cpp libcxx/test/libcxx/utilities/utility/private_constructor_tag.compile.pass.cpp libcxx/test/std/containers/sequences/array/array.fill/fill.verify.cpp libcxx/test/std/containers/sequences/array/array.swap/swap.verify.cpp libcxx/test/std/containers/sequences/array/array.tuple/get.verify.cpp libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.verify.cpp libcxx/test/std/containers/sequences/array/size_and_alignment.compile.pass.cpp libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp libcxx/test/std/containers/sequences/list/types.pass.cpp libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/default.pass.cpp libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/move.pass.cpp libcxx/test/std/input.output/string.streams/stringstream/stringstream.cons/string.pass.cpp libcxx/test/std/language.support/support.runtime/cstdalign.compile.pass.cpp libcxx/test/std/numerics/c.math/isnormal.pass.cpp libcxx/test/std/numerics/c.math/signbit.pass.cpp libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp libcxx/test/std/strings/basic.string/char.bad.verify.cpp libcxx/test/std/strings/string.view/char.bad.verify.cpp libcxx/test/std/utilities/template.bitset/bitset.members/nonstdmem.uglified.compile.pass.cpp libcxx/test/support/test_macros.h libcxx/test/tools/clang_tidy_checks/proper_version_checks.cpp The following files introduce new uses of undef:
Undef is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields In tests, avoid using For example, this is considered a bad practice: define void @fn() {
...
br i1 undef, ...
} Please use the following instead: define void @fn(i1 %cond) {
...
br i1 %cond, ...
} Please refer to the Undefined Behavior Manual for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to approve this with changes requested, and assuming CI is green. This should unblock you to keep moving forward over the holidays. I'd really like us to iterate in a separate branch until we gain a bit more confidence.
0e188c0
to
7b2f460
Compare
7b2f460
to
82a1289
Compare
This patch implements the forwarding to frozen C++03 headers as discussed in https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. In the RFC, we initially proposed selecting the right headers from the Clang driver, however consensus seemed to steer towards handling this in the library itself. This patch implements that direction.
At a high level, the changes basically amount to making each public header look like this:
In most cases, public headers are simple umbrella headers so there isn't much code in the #else branch. In other cases, the #else branch contains the actual implementation of the header.