Skip to content
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

Merged
merged 1 commit into from
Dec 21, 2024

Conversation

philnik777
Copy link
Contributor

@philnik777 philnik777 commented Sep 17, 2024

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:

// inside <vector>
#ifdef _LIBCPP_CXX03_LANG
#  include <__cxx03/vector>
#else
  // normal <vector> content
#endif

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.

Copy link
Contributor Author

philnik777 commented Sep 17, 2024

Copy link

github-actions bot commented Sep 17, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@philnik777 philnik777 marked this pull request as ready for review September 17, 2024 16:01
@philnik777 philnik777 requested a review from a team as a code owner September 17, 2024 16:01
@llvmbot llvmbot added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. github:workflow labels Sep 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2024

@llvm/pr-subscribers-libcxx

@llvm/pr-subscribers-github-workflow

Author: Nikolas Klauser (philnik777)

Changes

Patch is 902.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/109002.diff

131 Files Affected:

  • (modified) .github/workflows/libcxx-build-and-test.yaml (+1)
  • (added) libcxx/cmake/caches/cxx03-main-headers.cmake (+2)
  • (modified) libcxx/include/__config (+1)
  • (added) libcxx/include/__configuration/cxx03.h (+21)
  • (modified) libcxx/include/__cxx03/__config (-5)
  • (modified) libcxx/include/algorithm (+229-223)
  • (modified) libcxx/include/any (+72-66)
  • (modified) libcxx/include/array (+68-62)
  • (modified) libcxx/include/atomic (+47-41)
  • (modified) libcxx/include/barrier (+40-34)
  • (modified) libcxx/include/bit (+42-36)
  • (modified) libcxx/include/bitset (+60-54)
  • (modified) libcxx/include/cassert (+15-9)
  • (modified) libcxx/include/ccomplex (+6)
  • (modified) libcxx/include/cctype (+55-49)
  • (modified) libcxx/include/cerrno (+14-7)
  • (modified) libcxx/include/cfenv (+13-7)
  • (modified) libcxx/include/cfloat (+13-7)
  • (modified) libcxx/include/charconv (+43-37)
  • (modified) libcxx/include/chrono (+77-71)
  • (modified) libcxx/include/cinttypes (+14-8)
  • (modified) libcxx/include/ciso646 (+10-4)
  • (modified) libcxx/include/climits (+11-5)
  • (modified) libcxx/include/clocale (+12-6)
  • (modified) libcxx/include/cmath (+35-29)
  • (modified) libcxx/include/codecvt (+38-31)
  • (modified) libcxx/include/compare (+40-34)
  • (modified) libcxx/include/complex (+48-42)
  • (modified) libcxx/include/complex.h (+17-11)
  • (modified) libcxx/include/concepts (+46-40)
  • (modified) libcxx/include/condition_variable (+51-41)
  • (modified) libcxx/include/coroutine (+23-17)
  • (modified) libcxx/include/csetjmp (+15-9)
  • (modified) libcxx/include/csignal (+15-9)
  • (modified) libcxx/include/cstdarg (+15-9)
  • (modified) libcxx/include/cstdbool (+12-6)
  • (modified) libcxx/include/cstddef (+19-13)
  • (modified) libcxx/include/cstdint (+13-7)
  • (modified) libcxx/include/cstdio (+16-10)
  • (modified) libcxx/include/cstdlib (+20-14)
  • (modified) libcxx/include/cstring (+15-9)
  • (modified) libcxx/include/ctgmath (+11-5)
  • (modified) libcxx/include/ctime (+20-14)
  • (modified) libcxx/include/ctype.h (+34-28)
  • (modified) libcxx/include/cuchar (+18-12)
  • (modified) libcxx/include/cwchar (+33-27)
  • (modified) libcxx/include/cwctype (+16-10)
  • (modified) libcxx/include/deque (+176-170)
  • (modified) libcxx/include/errno.h (+274-268)
  • (modified) libcxx/include/exception (+22-16)
  • (modified) libcxx/include/execution (+24-18)
  • (modified) libcxx/include/expected (+26-20)
  • (modified) libcxx/include/fenv.h (+48-42)
  • (modified) libcxx/include/filesystem (+42-36)
  • (modified) libcxx/include/float.h (+21-15)
  • (modified) libcxx/include/format (+70-64)
  • (modified) libcxx/include/forward_list (+145-139)
  • (modified) libcxx/include/fstream (+140-134)
  • (modified) libcxx/include/functional (+73-67)
  • (modified) libcxx/include/future (+114-108)
  • (modified) libcxx/include/initializer_list (+13-7)
  • (modified) libcxx/include/inttypes.h (+21-15)
  • (modified) libcxx/include/iomanip (+34-28)
  • (modified) libcxx/include/ios (+66-60)
  • (modified) libcxx/include/iosfwd (+31-25)
  • (modified) libcxx/include/iostream (+17-11)
  • (modified) libcxx/include/istream (+132-126)
  • (modified) libcxx/include/iterator (+73-67)
  • (modified) libcxx/include/latch (+25-19)
  • (modified) libcxx/include/limits (+33-27)
  • (modified) libcxx/include/list (+168-162)
  • (modified) libcxx/include/locale (+164-158)
  • (modified) libcxx/include/locale.h (+13-7)
  • (modified) libcxx/include/map (+185-181)
  • (modified) libcxx/include/math.h (+88-82)
  • (modified) libcxx/include/mdspan (+32-26)
  • (modified) libcxx/include/memory (+58-52)
  • (modified) libcxx/include/memory_resource (+35-29)
  • (modified) libcxx/include/mutex (+52-46)
  • (modified) libcxx/include/new (+92-86)
  • (modified) libcxx/include/numbers (+18-12)
  • (modified) libcxx/include/numeric (+53-47)
  • (modified) libcxx/include/optional (+102-96)
  • (modified) libcxx/include/ostream (+30-24)
  • (modified) libcxx/include/print (+69-63)
  • (modified) libcxx/include/queue (+94-90)
  • (modified) libcxx/include/random (+63-57)
  • (modified) libcxx/include/ranges (+76-70)
  • (modified) libcxx/include/ratio (+31-27)
  • (modified) libcxx/include/regex (+160-154)
  • (modified) libcxx/include/scoped_allocator (+48-42)
  • (modified) libcxx/include/semaphore (+33-27)
  • (modified) libcxx/include/set (+157-155)
  • (modified) libcxx/include/shared_mutex (+34-28)
  • (modified) libcxx/include/source_location (+14-8)
  • (modified) libcxx/include/span (+89-83)
  • (modified) libcxx/include/sstream (+102-96)
  • (modified) libcxx/include/stack (+54-50)
  • (modified) libcxx/include/stdatomic.h (+20-16)
  • (modified) libcxx/include/stdbool.h (+23-17)
  • (modified) libcxx/include/stddef.h (+15-9)
  • (modified) libcxx/include/stdexcept (+64-58)
  • (modified) libcxx/include/stdint.h (+18-14)
  • (modified) libcxx/include/stdio.h (+22-16)
  • (modified) libcxx/include/stdlib.h (+39-33)
  • (modified) libcxx/include/stop_token (+21-15)
  • (modified) libcxx/include/streambuf (+30-24)
  • (modified) libcxx/include/string (+275-269)
  • (modified) libcxx/include/string.h (+19-12)
  • (modified) libcxx/include/string_view (+97-91)
  • (modified) libcxx/include/strstream (+30-24)
  • (modified) libcxx/include/syncstream (+50-44)
  • (modified) libcxx/include/system_error (+25-19)
  • (modified) libcxx/include/tgmath.h (+16-10)
  • (modified) libcxx/include/thread (+37-31)
  • (modified) libcxx/include/tuple (+109-103)
  • (modified) libcxx/include/type_traits (+107-101)
  • (modified) libcxx/include/typeindex (+23-17)
  • (modified) libcxx/include/typeinfo (+61-55)
  • (modified) libcxx/include/uchar.h (+19-13)
  • (modified) libcxx/include/unordered_map (+181-175)
  • (modified) libcxx/include/unordered_set (+148-144)
  • (modified) libcxx/include/utility (+56-50)
  • (modified) libcxx/include/valarray (+109-103)
  • (modified) libcxx/include/variant (+207-201)
  • (modified) libcxx/include/vector (+248-242)
  • (modified) libcxx/include/wchar.h (+34-28)
  • (modified) libcxx/include/wctype.h (+37-31)
  • (modified) libcxx/utils/ci/run-buildbot (+6)
  • (modified) libcxx/utils/generate_feature_test_macro_components.py (+6)
  • (modified) libcxx/utils/libcxx/test/params.py (+7)
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]

@Zingam
Copy link
Contributor

Zingam commented Oct 2, 2024

@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?

@philnik777
Copy link
Contributor Author

@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.

@philnik777 philnik777 force-pushed the users/philnik777/cxx03_fix_include_guards branch from e888ef3 to df30222 Compare October 30, 2024 14:59
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from 4d02649 to d7127f0 Compare October 30, 2024 14:59
Copy link
Member

@ldionne ldionne left a 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.

libcxx/include/algorithm Outdated Show resolved Hide resolved
libcxx/cmake/caches/cxx03-headers.cmake Outdated Show resolved Hide resolved
libcxx/include/__config Outdated Show resolved Hide resolved
libcxx/include/atomic Outdated Show resolved Hide resolved
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_fix_include_guards branch from df30222 to 34d0b52 Compare December 4, 2024 14:58
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from d7127f0 to f6850b2 Compare December 4, 2024 14:59
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_fix_include_guards branch from 34d0b52 to 83f8c8d Compare December 9, 2024 10:36
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from f6850b2 to 700c9c0 Compare December 9, 2024 10:36
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_fix_include_guards branch from 83f8c8d to bf624c9 Compare December 9, 2024 10:39
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from 700c9c0 to 055ae1f Compare December 9, 2024 10:39
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_fix_include_guards branch from bf624c9 to bea0f2b Compare December 9, 2024 11:15
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch 5 times, most recently from 6c1746f to b128fbe Compare December 9, 2024 14:59
Copy link
Member

@ldionne ldionne left a 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:

  1. Land the #if 0 change which addresses the formatting issues.
  2. Land the CMake changes that start installing the C++03 headers.
  3. 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.

libcxx/include/__flat_map/sorted_unique.h Outdated Show resolved Hide resolved
libcxx/include/__config Outdated Show resolved Hide resolved
libcxx/include/any Outdated Show resolved Hide resolved
Base automatically changed from users/philnik777/cxx03_fix_include_guards to main December 9, 2024 16:34
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from b128fbe to 5ea3719 Compare December 9, 2024 16:39
@philnik777 philnik777 changed the base branch from main to users/philnik777/cxx03_pp_experimental_ext December 11, 2024 11:03
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch 5 times, most recently from 2696de4 to 9497276 Compare December 11, 2024 15:26
Base automatically changed from users/philnik777/cxx03_pp_experimental_ext to main December 11, 2024 15:35
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from 9497276 to 6c87855 Compare December 11, 2024 15:37
Copy link
Member

@ldionne ldionne left a 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.

libcxx/include/CMakeLists.txt Outdated Show resolved Hide resolved
libcxx/include/__cxx03/CMakeLists.txt Outdated Show resolved Hide resolved
libcxx/utils/ci/run-buildbot Outdated Show resolved Hide resolved
libcxx/include/set Outdated Show resolved Hide resolved
libcxx/utils/generate_feature_test_macro_components.py Outdated Show resolved Hide resolved
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from 6c87855 to 0e188c0 Compare December 20, 2024 14:51
Copy link

github-actions bot commented Dec 20, 2024

⚠️ undef deprecator found issues in your code. ⚠️

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:

  • libcxx/include/__cxx03/__configuration/config_site_shim.h

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 undef. You should use poison values for placeholders instead.

In tests, avoid using undef and having tests that trigger undefined behavior. If you need an operand with some unimportant value, you can add a new argument to the function and use that instead.

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.

Copy link
Member

@ldionne ldionne left a 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.

libcxx/include/CMakeLists.txt Outdated Show resolved Hide resolved
libcxx/include/CMakeLists.txt Outdated Show resolved Hide resolved
libcxx/include/CMakeLists.txt Outdated Show resolved Hide resolved
libcxx/include/__cxx03/__configuration/config_site_shim.h Outdated Show resolved Hide resolved
libcxx/utils/generate_feature_test_macro_components.py Outdated Show resolved Hide resolved
libcxx/test/libcxx/feature_test_macro/version_header.sh.py Outdated Show resolved Hide resolved
libcxx/include/version Outdated Show resolved Hide resolved
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from 0e188c0 to 7b2f460 Compare December 20, 2024 17:58
@philnik777 philnik777 force-pushed the users/philnik777/cxx03_use_headers branch from 7b2f460 to 82a1289 Compare December 20, 2024 18:24
@philnik777 philnik777 merged commit b9a2658 into main Dec 21, 2024
62 of 63 checks passed
@philnik777 philnik777 deleted the users/philnik777/cxx03_use_headers branch December 21, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github:workflow libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants