Skip to content

Revert "[libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (#131156)" #141756

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
merged 4 commits into from
May 28, 2025

Conversation

jyknight
Copy link
Member

@jyknight jyknight commented May 28, 2025

This reverts commit c861fe8.

Unfortunately, this use of hidden visibility attributes causes user-defined specializations of standard-library types to also be marked hidden by default, which is incorrect. See discussion thread on #131156.

...and also reverts the follow-up commits:

Revert "[libc++] Add explicit ABI annotations to functions from the block runtime declared in <__functional/function.h> (#140592)"
This reverts commit 3e4c9dc.

Revert "[libc++] Make ABI annotations explicit for windows-specific code (#140507)"
This reverts commit f73287e.

Revert "[libc++][NFC] Replace a few "namespace std" with the correct macro (#140510)"
This reverts commit 1d411f2.

@jyknight jyknight requested a review from a team as a code owner May 28, 2025 13:04
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 28, 2025
@llvmbot
Copy link
Member

llvmbot commented May 28, 2025

@llvm/pr-subscribers-libcxx

Author: James Y Knight (jyknight)

Changes

...and also the two follow-up commits:
Revert "[libc++] Add explicit ABI annotations to functions from the block runtime declared in <__functional/function.h> (#140592)"
Revert "[libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (#131156)"

This reverts commit 3e4c9dc.
This reverts commit f73287e.
This reverts commit c861fe8.


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

123 Files Affected:

  • (modified) libcxx/include/__algorithm/shuffle.h (-2)
  • (modified) libcxx/include/__algorithm/sort.h (+31-30)
  • (modified) libcxx/include/__atomic/atomic_sync.h (-2)
  • (modified) libcxx/include/__charconv/from_chars_floating_point.h (-2)
  • (modified) libcxx/include/__charconv/to_chars_floating_point.h (+3-6)
  • (modified) libcxx/include/__chrono/exception.h (-2)
  • (modified) libcxx/include/__chrono/file_clock.h (-2)
  • (modified) libcxx/include/__chrono/steady_clock.h (-2)
  • (modified) libcxx/include/__chrono/system_clock.h (-2)
  • (modified) libcxx/include/__condition_variable/condition_variable.h (-2)
  • (modified) libcxx/include/__config (+5-15)
  • (modified) libcxx/include/__exception/exception.h (-2)
  • (modified) libcxx/include/__exception/exception_ptr.h (-3)
  • (modified) libcxx/include/__exception/nested_exception.h (-2)
  • (modified) libcxx/include/__exception/operations.h (-2)
  • (modified) libcxx/include/__exception/terminate.h (-2)
  • (modified) libcxx/include/__expected/bad_expected_access.h (-2)
  • (modified) libcxx/include/__filesystem/directory_entry.h (-2)
  • (modified) libcxx/include/__filesystem/directory_iterator.h (-2)
  • (modified) libcxx/include/__filesystem/filesystem_error.h (-2)
  • (modified) libcxx/include/__filesystem/operations.h (-2)
  • (modified) libcxx/include/__filesystem/path.h (-2)
  • (modified) libcxx/include/__filesystem/path_iterator.h (-2)
  • (modified) libcxx/include/__filesystem/recursive_directory_iterator.h (-2)
  • (modified) libcxx/include/__format/format_error.h (-2)
  • (modified) libcxx/include/__functional/function.h (+2-9)
  • (modified) libcxx/include/__functional/hash.h (-2)
  • (modified) libcxx/include/__hash_table (-2)
  • (modified) libcxx/include/__locale (-2)
  • (modified) libcxx/include/__locale_dir/support/windows.h (-6)
  • (modified) libcxx/include/__memory/align.h (-2)
  • (modified) libcxx/include/__memory/shared_count.h (-2)
  • (modified) libcxx/include/__memory/shared_ptr.h (-10)
  • (modified) libcxx/include/__memory_resource/memory_resource.h (-2)
  • (modified) libcxx/include/__memory_resource/monotonic_buffer_resource.h (-2)
  • (modified) libcxx/include/__memory_resource/synchronized_pool_resource.h (-2)
  • (modified) libcxx/include/__memory_resource/unsynchronized_pool_resource.h (-2)
  • (modified) libcxx/include/__mutex/mutex.h (-2)
  • (modified) libcxx/include/__mutex/once_flag.h (-2)
  • (modified) libcxx/include/__new/exceptions.h (-2)
  • (modified) libcxx/include/__new/new_handler.h (-2)
  • (modified) libcxx/include/__ostream/basic_ostream.h (-2)
  • (modified) libcxx/include/__ostream/print.h (-2)
  • (modified) libcxx/include/__pstl/backends/libdispatch.h (-4)
  • (modified) libcxx/include/__random/binomial_distribution.h (+1-3)
  • (modified) libcxx/include/__random/random_device.h (-2)
  • (modified) libcxx/include/__system_error/error_category.h (-2)
  • (modified) libcxx/include/__system_error/error_code.h (-2)
  • (modified) libcxx/include/__system_error/error_condition.h (-2)
  • (modified) libcxx/include/__system_error/system_error.h (-2)
  • (modified) libcxx/include/__system_error/throw_system_error.h (-2)
  • (modified) libcxx/include/__thread/support/windows.h (-2)
  • (modified) libcxx/include/__thread/this_thread.h (-2)
  • (modified) libcxx/include/__thread/thread.h (-2)
  • (modified) libcxx/include/__verbose_abort (-2)
  • (modified) libcxx/include/any (-2)
  • (modified) libcxx/include/barrier (-2)
  • (modified) libcxx/include/codecvt (-2)
  • (modified) libcxx/include/condition_variable (-2)
  • (modified) libcxx/include/fstream (-2)
  • (modified) libcxx/include/future (-2)
  • (modified) libcxx/include/ios (-2)
  • (modified) libcxx/include/istream (-2)
  • (modified) libcxx/include/locale (-2)
  • (modified) libcxx/include/mutex (-2)
  • (modified) libcxx/include/print (-2)
  • (modified) libcxx/include/regex (-2)
  • (modified) libcxx/include/shared_mutex (-4)
  • (modified) libcxx/include/sstream (-2)
  • (modified) libcxx/include/stdexcept (-2)
  • (modified) libcxx/include/streambuf (-2)
  • (modified) libcxx/include/string (-2)
  • (modified) libcxx/include/strstream (-2)
  • (modified) libcxx/include/valarray (-2)
  • (modified) libcxx/include/variant (+2-2)
  • (modified) libcxx/src/algorithm.cpp (-2)
  • (modified) libcxx/src/any.cpp (-2)
  • (modified) libcxx/src/atomic.cpp (-2)
  • (modified) libcxx/src/barrier.cpp (-2)
  • (modified) libcxx/src/call_once.cpp (-2)
  • (modified) libcxx/src/charconv.cpp (-3)
  • (modified) libcxx/src/chrono.cpp (-2)
  • (modified) libcxx/src/condition_variable.cpp (-2)
  • (modified) libcxx/src/condition_variable_destructor.cpp (-2)
  • (modified) libcxx/src/error_category.cpp (-2)
  • (modified) libcxx/src/expected.cpp (-4)
  • (modified) libcxx/src/experimental/chrono_exception.cpp (-2)
  • (modified) libcxx/src/filesystem/directory_entry.cpp (-2)
  • (modified) libcxx/src/filesystem/directory_iterator.cpp (-2)
  • (modified) libcxx/src/filesystem/filesystem_clock.cpp (-2)
  • (modified) libcxx/src/filesystem/filesystem_error.cpp (-2)
  • (modified) libcxx/src/filesystem/operations.cpp (-2)
  • (modified) libcxx/src/filesystem/path.cpp (-2)
  • (modified) libcxx/src/fstream.cpp (-2)
  • (modified) libcxx/src/functional.cpp (-2)
  • (modified) libcxx/src/future.cpp (-2)
  • (modified) libcxx/src/hash.cpp (-2)
  • (modified) libcxx/src/ios.cpp (-2)
  • (modified) libcxx/src/iostream.cpp (-2)
  • (modified) libcxx/src/locale.cpp (-2)
  • (modified) libcxx/src/memory.cpp (-2)
  • (modified) libcxx/src/memory_resource.cpp (-2)
  • (modified) libcxx/src/mutex.cpp (-2)
  • (modified) libcxx/src/mutex_destructor.cpp (-2)
  • (modified) libcxx/src/optional.cpp (-2)
  • (modified) libcxx/src/ostream.cpp (-2)
  • (modified) libcxx/src/print.cpp (-2)
  • (modified) libcxx/src/random.cpp (-2)
  • (modified) libcxx/src/random_shuffle.cpp (-2)
  • (modified) libcxx/src/regex.cpp (-2)
  • (modified) libcxx/src/shared_mutex.cpp (-2)
  • (modified) libcxx/src/std_stream.h (-2)
  • (modified) libcxx/src/stdexcept.cpp (-2)
  • (modified) libcxx/src/string.cpp (-2)
  • (modified) libcxx/src/strstream.cpp (-2)
  • (modified) libcxx/src/support/win32/locale_win32.cpp (-2)
  • (modified) libcxx/src/support/win32/thread_win32.cpp (-2)
  • (modified) libcxx/src/system_error.cpp (-2)
  • (modified) libcxx/src/thread.cpp (-2)
  • (modified) libcxx/src/valarray.cpp (-2)
  • (modified) libcxx/src/vector.cpp (-2)
  • (modified) libcxx/src/verbose_abort.cpp (-2)
  • (modified) libcxx/test/tools/clang_tidy_checks/hide_from_abi.cpp (+10)
diff --git a/libcxx/include/__algorithm/shuffle.h b/libcxx/include/__algorithm/shuffle.h
index d50746f24f782..7177fbb469ba7 100644
--- a/libcxx/include/__algorithm/shuffle.h
+++ b/libcxx/include/__algorithm/shuffle.h
@@ -65,7 +65,6 @@ class _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_randomizer {
 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) || defined(_LIBCPP_BUILDING_LIBRARY)
 class _LIBCPP_EXPORTED_FROM_ABI __rs_default;
 
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_EXPORTED_FROM_ABI __rs_default __rs_get();
 
 class _LIBCPP_EXPORTED_FROM_ABI __rs_default {
@@ -91,7 +90,6 @@ class _LIBCPP_EXPORTED_FROM_ABI __rs_default {
 };
 
 _LIBCPP_EXPORTED_FROM_ABI __rs_default __rs_get();
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 
 template <class _RandomAccessIterator>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index ba5b2e681f6bc..06cb5b8ce7057 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -64,7 +64,7 @@ enum { __block_size = sizeof(uint64_t) * 8 };
 
 // Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.
 template <class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
 __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {
   // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
   using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
@@ -78,7 +78,7 @@ __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c)
 // Ensures that *__x, *__y and *__z are ordered according to the comparator __c,
 // under the assumption that *__y and *__z are already ordered.
 template <class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
 __partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _RandomAccessIterator __z, _Compare __c) {
   // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
   using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
@@ -97,7 +97,7 @@ template <class,
           class _Compare,
           class _RandomAccessIterator,
           __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
 __sort3(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) {
   bool __swapped1 = std::__cond_swap<_Compare>(__x2, __x3, __c);
   bool __swapped2 = std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
@@ -108,7 +108,7 @@ template <class _AlgPolicy,
           class _Compare,
           class _RandomAccessIterator,
           __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
 __sort3(_RandomAccessIterator __x, _RandomAccessIterator __y, _RandomAccessIterator __z, _Compare __c) {
   using _Ops = _IterOps<_AlgPolicy>;
 
@@ -140,7 +140,7 @@ template <class,
           class _Compare,
           class _RandomAccessIterator,
           __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
-inline void
+inline _LIBCPP_HIDE_FROM_ABI void
 __sort4(_RandomAccessIterator __x1,
         _RandomAccessIterator __x2,
         _RandomAccessIterator __x3,
@@ -157,7 +157,7 @@ template <class _AlgPolicy,
           class _Compare,
           class _RandomAccessIterator,
           __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
-inline void
+inline _LIBCPP_HIDE_FROM_ABI void
 __sort4(_RandomAccessIterator __x1,
         _RandomAccessIterator __x2,
         _RandomAccessIterator __x3,
@@ -182,7 +182,7 @@ template <class _AlgPolicy,
           class _Compare,
           class _RandomAccessIterator,
           __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
-inline void
+inline _LIBCPP_HIDE_FROM_ABI void
 __sort5(_RandomAccessIterator __x1,
         _RandomAccessIterator __x2,
         _RandomAccessIterator __x3,
@@ -201,7 +201,7 @@ template <class _AlgPolicy,
           class _Compare,
           class _RandomAccessIterator,
           __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
-inline void
+inline _LIBCPP_HIDE_FROM_ABI void
 __sort5(_RandomAccessIterator __x1,
         _RandomAccessIterator __x2,
         _RandomAccessIterator __x3,
@@ -227,7 +227,7 @@ __sort5(_RandomAccessIterator __x1,
 
 // Assumes size > 0
 template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_SINCE_CXX14 void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
 __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
   _BidirectionalIterator __lm1 = __last;
   for (--__lm1; __first != __lm1; ++__first) {
@@ -240,7 +240,7 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
 // Sort the iterator range [__first, __last) using the comparator __comp using
 // the insertion sort algorithm.
 template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_SINCE_CXX26 void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
 __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
   using _Ops = _IterOps<_AlgPolicy>;
 
@@ -270,7 +270,8 @@ __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
 // Assumes that there is an element in the position (__first - 1) and that each
 // element in the input range is greater or equal to the element at __first - 1.
 template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-void __insertion_sort_unguarded(_RandomAccessIterator const __first, _RandomAccessIterator __last, _Compare __comp) {
+_LIBCPP_HIDE_FROM_ABI void
+__insertion_sort_unguarded(_RandomAccessIterator const __first, _RandomAccessIterator __last, _Compare __comp) {
   using _Ops = _IterOps<_AlgPolicy>;
   typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
   typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
@@ -297,7 +298,8 @@ void __insertion_sort_unguarded(_RandomAccessIterator const __first, _RandomAcce
 }
 
 template <class _AlgPolicy, class _Comp, class _RandomAccessIterator>
-bool __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
+_LIBCPP_HIDE_FROM_ABI bool
+__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
   using _Ops = _IterOps<_AlgPolicy>;
 
   typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -350,7 +352,7 @@ bool __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIte
 }
 
 template <class _AlgPolicy, class _RandomAccessIterator>
-inline void __swap_bitmap_pos(
+inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos(
     _RandomAccessIterator __first, _RandomAccessIterator __last, uint64_t& __left_bitset, uint64_t& __right_bitset) {
   using _Ops = _IterOps<_AlgPolicy>;
   typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -368,7 +370,7 @@ inline void __swap_bitmap_pos(
 template <class _Compare,
           class _RandomAccessIterator,
           class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
-inline void
+inline _LIBCPP_HIDE_FROM_ABI void
 __populate_left_bitset(_RandomAccessIterator __first, _Compare __comp, _ValueType& __pivot, uint64_t& __left_bitset) {
   // Possible vectorization. With a proper "-march" flag, the following loop
   // will be compiled into a set of SIMD instructions.
@@ -384,7 +386,7 @@ __populate_left_bitset(_RandomAccessIterator __first, _Compare __comp, _ValueTyp
 template <class _Compare,
           class _RandomAccessIterator,
           class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
-inline void
+inline _LIBCPP_HIDE_FROM_ABI void
 __populate_right_bitset(_RandomAccessIterator __lm1, _Compare __comp, _ValueType& __pivot, uint64_t& __right_bitset) {
   // Possible vectorization. With a proper "-march" flag, the following loop
   // will be compiled into a set of SIMD instructions.
@@ -401,7 +403,7 @@ template <class _AlgPolicy,
           class _Compare,
           class _RandomAccessIterator,
           class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
-inline void __bitset_partition_partial_blocks(
+inline _LIBCPP_HIDE_FROM_ABI void __bitset_partition_partial_blocks(
     _RandomAccessIterator& __first,
     _RandomAccessIterator& __lm1,
     _Compare __comp,
@@ -448,7 +450,7 @@ inline void __bitset_partition_partial_blocks(
 }
 
 template <class _AlgPolicy, class _RandomAccessIterator>
-inline void __swap_bitmap_pos_within(
+inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within(
     _RandomAccessIterator& __first, _RandomAccessIterator& __lm1, uint64_t& __left_bitset, uint64_t& __right_bitset) {
   using _Ops = _IterOps<_AlgPolicy>;
   typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -489,7 +491,7 @@ inline void __swap_bitmap_pos_within(
 // __bitset_partition uses bitsets for storing outcomes of the comparisons
 // between the pivot and other elements.
 template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
-std::pair<_RandomAccessIterator, bool>
+_LIBCPP_HIDE_FROM_ABI std::pair<_RandomAccessIterator, bool>
 __bitset_partition(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
   using _Ops = _IterOps<_AlgPolicy>;
   typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
@@ -581,7 +583,7 @@ __bitset_partition(_RandomAccessIterator __first, _RandomAccessIterator __last,
 // the provided range is already sorted, false otherwise.  We assume that the
 // length of the range is at least three elements.
 template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
-std::pair<_RandomAccessIterator, bool>
+_LIBCPP_HIDE_FROM_ABI std::pair<_RandomAccessIterator, bool>
 __partition_with_equals_on_right(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
   using _Ops = _IterOps<_AlgPolicy>;
   typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -649,7 +651,7 @@ __partition_with_equals_on_right(_RandomAccessIterator __first, _RandomAccessIte
 // Similar to the above function.  Elements equivalent to the pivot are put to
 // the left of the pivot.  Returns the iterator to the pivot element.
 template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
-_RandomAccessIterator
+_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator
 __partition_with_equals_on_left(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
   using _Ops = _IterOps<_AlgPolicy>;
   typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -826,7 +828,6 @@ void __introsort(_RandomAccessIterator __first,
   }
 }
 
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 template <class _Comp, class _RandomAccessIterator>
 void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);
 
@@ -855,10 +856,9 @@ extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<float>&, float*>(fl
 extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
 extern template _LIBCPP_EXPORTED_FROM_ABI void
 __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 
 template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
-_LIBCPP_CONSTEXPR_SINCE_CXX20 void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
   typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
   difference_type __depth_limit = 2 * std::__bit_log2(std::__to_unsigned_like(__last - __first));
@@ -895,20 +895,20 @@ using __sort_is_specialized_in_library _LIBCPP_NODEBUG = __is_any_of<
     long double>;
 
 template <class _AlgPolicy, class _Type, __enable_if_t<__sort_is_specialized_in_library<_Type>::value, int> = 0>
-void __sort_dispatch(_Type* __first, _Type* __last, __less<>&) {
+_LIBCPP_HIDE_FROM_ABI void __sort_dispatch(_Type* __first, _Type* __last, __less<>&) {
   __less<_Type> __comp;
   std::__sort<__less<_Type>&, _Type*>(__first, __last, __comp);
 }
 
 template <class _AlgPolicy, class _Type, __enable_if_t<__sort_is_specialized_in_library<_Type>::value, int> = 0>
-void __sort_dispatch(_Type* __first, _Type* __last, less<_Type>&) {
+_LIBCPP_HIDE_FROM_ABI void __sort_dispatch(_Type* __first, _Type* __last, less<_Type>&) {
   __less<_Type> __comp;
   std::__sort<__less<_Type>&, _Type*>(__first, __last, __comp);
 }
 
 #if _LIBCPP_STD_VER >= 14
 template <class _AlgPolicy, class _Type, __enable_if_t<__sort_is_specialized_in_library<_Type>::value, int> = 0>
-void __sort_dispatch(_Type* __first, _Type* __last, less<>&) {
+_LIBCPP_HIDE_FROM_ABI void __sort_dispatch(_Type* __first, _Type* __last, less<>&) {
   __less<_Type> __comp;
   std::__sort<__less<_Type>&, _Type*>(__first, __last, __comp);
 }
@@ -916,14 +916,14 @@ void __sort_dispatch(_Type* __first, _Type* __last, less<>&) {
 
 #if _LIBCPP_STD_VER >= 20
 template <class _AlgPolicy, class _Type, __enable_if_t<__sort_is_specialized_in_library<_Type>::value, int> = 0>
-void __sort_dispatch(_Type* __first, _Type* __last, ranges::less&) {
+_LIBCPP_HIDE_FROM_ABI void __sort_dispatch(_Type* __first, _Type* __last, ranges::less&) {
   __less<_Type> __comp;
   std::__sort<__less<_Type>&, _Type*>(__first, __last, __comp);
 }
 #endif
 
 template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
   std::__debug_randomize_range<_AlgPolicy>(__first, __last);
 
@@ -937,13 +937,14 @@ __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp&
 }
 
 template <class _RandomAccessIterator, class _Comp>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
   std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
 }
 
 template <class _RandomAccessIterator>
-inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
+sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
   std::sort(__first, __last, __less<>());
 }
 
diff --git a/libcxx/include/__atomic/atomic_sync.h b/libcxx/include/__atomic/atomic_sync.h
index 89d886b47b569..0dae448d649be 100644
--- a/libcxx/include/__atomic/atomic_sync.h
+++ b/libcxx/include/__atomic/atomic_sync.h
@@ -58,7 +58,6 @@ struct __atomic_waitable< _Tp,
 #if _LIBCPP_STD_VER >= 20
 #  if _LIBCPP_HAS_THREADS
 
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT;
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
@@ -74,7 +73,6 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
 __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*) _NOEXCEPT;
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
 __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t) _NOEXCEPT;
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 
 template <class _AtomicWaitable, class _Poll>
 struct __atomic_wait_backoff_impl {
diff --git a/libcxx/include/__charconv/from_chars_floating_point.h b/libcxx/include/__charconv/from_chars_floating_point.h
index ed7c54ae58261..811e518a81db7 100644
--- a/libcxx/include/__charconv/from_chars_floating_point.h
+++ b/libcxx/include/__charconv/from_chars_floating_point.h
@@ -35,7 +35,6 @@ struct __from_chars_result {
   errc __ec;
 };
 
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 template <class _Fp>
 _LIBCPP_EXPORTED_FROM_ABI __from_chars_result<_Fp> __from_chars_floating_point(
     _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
@@ -45,7 +44,6 @@ extern template __from_chars_result<float> __from_chars_floating_point(
 
 extern template __from_chars_result<double> __from_chars_floating_point(
     _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 
 template <class _Fp>
 _LIBCPP_HIDE_FROM_ABI from_chars_result
diff --git a/libcxx/include/__charconv/to_chars_floating_point.h b/libcxx/include/__charconv/to_chars_floating_point.h
index 2deda89723f36..118f316b21a10 100644
--- a/libcxx/include/__charconv/to_chars_floating_point.h
+++ b/libcxx/include/__charconv/to_chars_floating_point.h
@@ -18,10 +18,9 @@
 #  pragma GCC system_header
 #endif
 
-#if _LIBCPP_STD_VER >= 17
-
 _LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
+
+#if _LIBCPP_STD_VER >= 17
 
 _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
 to_chars(char* __first, char* __last, float __value);
@@ -49,10 +48,8 @@ to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __
 
 _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
 to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
+#endif // _LIBCPP_STD_VER >= 17
 
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // _LIBCPP_STD_VER >= 17
-
 #endif // _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h
index 27fbfd6b57a2b..1eb5b1b62d92c 100644
--- a/libcxx/include/__chrono/exception.h
+++ b/libcxx/include/__chrono/exception.h
@@ -31,7 +31,6 @@
 #  endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 #  if _LIBCPP_STD_VER >= 20
 
@@ -129,7 +128,6 @@ template <class _Duration>
 
 #  endif // _LIBCPP_STD_VER >= 20
 
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
diff --git a/libcxx/include/__chrono/file_clock.h b/libcxx/include/__chrono/file_clock.h
index 82e853cd35a7a..b4b7e9dc14e70 100644
--- a/libcxx/include/__chrono/file_clock.h
+++ b/libcxx/include/__chrono/file_clock.h
@@ -46,7 +46,6 @@ _LIBCPP_END_NAMESPACE_STD
 
 #ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 struct _FilesystemClock {
 #  if _LIBCPP_HAS_INT128
   typedef __int128_t rep;
@@ -75,7 +74,6 @@ struct _FilesystemClock {
   }
 #  endif // _LIBCPP_STD_VER >= 20
 };
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_END_NAMESPACE_FILESYSTEM
 #endif // !_LIBCPP_CXX03_LANG
 
diff --git a/libcxx/include/__chrono/steady_clock.h b/libcxx/include/__chrono/steady_clock.h
index b706e24a5951a..1b247b2c28609 100644
--- a/libcxx/include/__chrono/steady_clock.h
+++ b/libcxx/include/__chrono/steady_clock.h
@@ -19,7 +19,6 @@
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 namespace chrono {
 
@@ -38,7 +37,6 @@ class _LIBCPP_EXPORTED_FROM_ABI steady_clock {
 
 } // namespace chrono
 
-_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___CHRONO_STEADY_CLOCK_H
diff --git a/libcxx/include/__chrono/system_clock.h b/libcxx/include/__chrono/system_clock.h
index 1bffa04254da1..5a9eb65bdae7a 100644
...
[truncated]

Copy link

github-actions bot commented May 28, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions ,cpp,h -- libcxx/include/__algorithm/shuffle.h libcxx/include/__algorithm/sort.h libcxx/include/__atomic/atomic_sync.h libcxx/include/__charconv/from_chars_floating_point.h libcxx/include/__charconv/to_chars_floating_point.h libcxx/include/__chrono/exception.h libcxx/include/__chrono/file_clock.h libcxx/include/__chrono/steady_clock.h libcxx/include/__chrono/system_clock.h libcxx/include/__condition_variable/condition_variable.h libcxx/include/__config libcxx/include/__exception/exception.h libcxx/include/__exception/exception_ptr.h libcxx/include/__exception/nested_exception.h libcxx/include/__exception/operations.h libcxx/include/__exception/terminate.h libcxx/include/__expected/bad_expected_access.h libcxx/include/__filesystem/directory_entry.h libcxx/include/__filesystem/directory_iterator.h libcxx/include/__filesystem/filesystem_error.h libcxx/include/__filesystem/operations.h libcxx/include/__filesystem/path.h libcxx/include/__filesystem/path_iterator.h libcxx/include/__filesystem/recursive_directory_iterator.h libcxx/include/__format/format_error.h libcxx/include/__functional/function.h libcxx/include/__functional/hash.h libcxx/include/__hash_table libcxx/include/__locale libcxx/include/__locale_dir/support/windows.h libcxx/include/__memory/align.h libcxx/include/__memory/shared_count.h libcxx/include/__memory/shared_ptr.h libcxx/include/__memory_resource/memory_resource.h libcxx/include/__memory_resource/monotonic_buffer_resource.h libcxx/include/__memory_resource/synchronized_pool_resource.h libcxx/include/__memory_resource/unsynchronized_pool_resource.h libcxx/include/__mutex/mutex.h libcxx/include/__mutex/once_flag.h libcxx/include/__new/exceptions.h libcxx/include/__new/new_handler.h libcxx/include/__ostream/basic_ostream.h libcxx/include/__ostream/print.h libcxx/include/__pstl/backends/libdispatch.h libcxx/include/__random/binomial_distribution.h libcxx/include/__random/random_device.h libcxx/include/__system_error/error_category.h libcxx/include/__system_error/error_code.h libcxx/include/__system_error/error_condition.h libcxx/include/__system_error/system_error.h libcxx/include/__system_error/throw_system_error.h libcxx/include/__thread/support/windows.h libcxx/include/__thread/this_thread.h libcxx/include/__thread/thread.h libcxx/include/__verbose_abort libcxx/include/any libcxx/include/barrier libcxx/include/codecvt libcxx/include/condition_variable libcxx/include/fstream libcxx/include/future libcxx/include/initializer_list libcxx/include/ios libcxx/include/istream libcxx/include/locale libcxx/include/mutex libcxx/include/optional libcxx/include/print libcxx/include/regex libcxx/include/shared_mutex libcxx/include/sstream libcxx/include/stdexcept libcxx/include/streambuf libcxx/include/string libcxx/include/strstream libcxx/include/typeinfo libcxx/include/valarray libcxx/include/variant libcxx/src/algorithm.cpp libcxx/src/any.cpp libcxx/src/atomic.cpp libcxx/src/barrier.cpp libcxx/src/call_once.cpp libcxx/src/charconv.cpp libcxx/src/chrono.cpp libcxx/src/condition_variable.cpp libcxx/src/condition_variable_destructor.cpp libcxx/src/error_category.cpp libcxx/src/expected.cpp libcxx/src/experimental/chrono_exception.cpp libcxx/src/filesystem/directory_entry.cpp libcxx/src/filesystem/directory_iterator.cpp libcxx/src/filesystem/filesystem_clock.cpp libcxx/src/filesystem/filesystem_error.cpp libcxx/src/filesystem/operations.cpp libcxx/src/filesystem/path.cpp libcxx/src/fstream.cpp libcxx/src/functional.cpp libcxx/src/future.cpp libcxx/src/hash.cpp libcxx/src/ios.cpp libcxx/src/iostream.cpp libcxx/src/locale.cpp libcxx/src/memory.cpp libcxx/src/memory_resource.cpp libcxx/src/mutex.cpp libcxx/src/mutex_destructor.cpp libcxx/src/optional.cpp libcxx/src/ostream.cpp libcxx/src/print.cpp libcxx/src/random.cpp libcxx/src/random_shuffle.cpp libcxx/src/regex.cpp libcxx/src/shared_mutex.cpp libcxx/src/std_stream.h libcxx/src/stdexcept.cpp libcxx/src/string.cpp libcxx/src/strstream.cpp libcxx/src/support/win32/locale_win32.cpp libcxx/src/support/win32/thread_win32.cpp libcxx/src/system_error.cpp libcxx/src/thread.cpp libcxx/src/valarray.cpp libcxx/src/vector.cpp libcxx/src/verbose_abort.cpp libcxx/test/tools/clang_tidy_checks/hide_from_abi.cpp
View the diff from clang-format here.
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index f8b696733..73295cae4 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -20,8 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // This function should never be called directly from the code -- it should only be called through
 // the _LIBCPP_VERBOSE_ABORT macro.
-[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(
-    __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
+[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
+_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
 
 // _LIBCPP_VERBOSE_ABORT(format, args...)
 //

@jyknight
Copy link
Member Author

Given that this is a revert that is restoring the code to the previous state, I will ignore the "Check code formatting" presubmit failure.

Copy link
Contributor

@philnik777 philnik777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming the CI is green (or at least as green as it gets currently).

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if CI is happy, thank you!

@jyknight
Copy link
Member Author

The failed tests are all unrelated infrastructure failures. Merging.

@jyknight jyknight merged commit c3656af into llvm:main May 28, 2025
85 of 92 checks passed
@jyknight jyknight deleted the revert-libcxx-abi-macros branch May 28, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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