Skip to content

[libc++][NFC] Add a few clang-format annotations #74352

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 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libcxx/include/__availability
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@
# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS

// <filesystem>
// clang-format off
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000)
// clang-format on
# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 0
# else
# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1
Expand All @@ -178,6 +180,7 @@
__attribute__((availability(ios,strict,introduced=13.0))) \
__attribute__((availability(tvos,strict,introduced=13.0))) \
__attribute__((availability(watchos,strict,introduced=6.0)))
// clang-format off
# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH \
_Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
_Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
Expand All @@ -188,12 +191,15 @@
_Pragma("clang attribute pop") \
_Pragma("clang attribute pop") \
_Pragma("clang attribute pop")
// clang-format on

// std::to_chars(floating-point)
// clang-format off
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130300) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160300) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160300) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90300)
// clang-format on
# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 0
# else
# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 1
Expand All @@ -205,10 +211,12 @@
__attribute__((availability(watchos,strict,introduced=9.3)))

// c++20 synchronization library
// clang-format off
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
// clang-format on
# define _LIBCPP_AVAILABILITY_HAS_SYNC 0
# else
# define _LIBCPP_AVAILABILITY_HAS_SYNC 1
Expand All @@ -227,10 +235,12 @@
__attribute__((unavailable))

// std::pmr
// clang-format off
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000)
// clang-format on
# define _LIBCPP_AVAILABILITY_HAS_PMR 0
# else
# define _LIBCPP_AVAILABILITY_HAS_PMR 1
Expand All @@ -252,10 +262,12 @@
# define _LIBCPP_AVAILABILITY_HAS_TZDB 0
# define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable))

// clang-format off
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120000) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150000) || \
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150000) || \
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80000)
// clang-format on
# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
# else
# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 1
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/__format/escaped_output_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 23

namespace __escaped_output_table {
// clang-format off

/// The entries of the characters to escape in format's debug string.
///
Expand Down Expand Up @@ -1029,6 +1030,7 @@ inline constexpr uint32_t __unallocated_region_lower_bound = 0x000323b0;
return __code_point <= __upper_bound;
}

// clang-format on
} // namespace __escaped_output_table

#endif //_LIBCPP_STD_VER >= 23
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/__format/extended_grapheme_cluster_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ enum class __property : uint8_t {
/// this approach uses less space for the data and is about 4% faster in the
/// following benchmark.
/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
// clang-format off
inline constexpr uint32_t __entries[1496] = {
0x00000091,
0x00005005,
Expand Down Expand Up @@ -1621,6 +1622,7 @@ inline constexpr uint32_t __entries[1496] = {
0x707787f1,
0x707b87f1,
0x707f80f1};
// clang-format on

/// Returns the extended grapheme cluster bondary property of a code point.
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/__iterator/iter_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ namespace __iter_swap {
}

template <class _T1, class _T2>
requires (!__unqualified_iter_swap<_T1, _T2> &&
!__readable_swappable<_T1, _T2>) &&
indirectly_movable_storable<_T1, _T2> &&
requires (!__unqualified_iter_swap<_T1, _T2> && //
!__readable_swappable<_T1, _T2>) && //
indirectly_movable_storable<_T1, _T2> && //
indirectly_movable_storable<_T2, _T1>
_LIBCPP_HIDE_FROM_ABI
constexpr void operator()(_T1&& __x, _T2&& __y) const
noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) &&
noexcept(*__y = ranges::iter_move(__x)) &&
noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) && //
noexcept(*__y = ranges::iter_move(__x)) && //
noexcept(*_VSTD::forward<_T1>(__x) = std::declval<iter_value_t<_T2>>()))
{
iter_value_t<_T2> __old(ranges::iter_move(__y));
Expand Down
3 changes: 3 additions & 0 deletions libcxx/include/__string/extern_template_lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# pragma GCC system_header
#endif

// clang-format off

// We maintain 2 ABI lists:
// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST
// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST
Expand Down Expand Up @@ -126,5 +128,6 @@
_Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::resize(size_type, value_type)) \
_Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))

// clang-format on

#endif // _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H
2 changes: 2 additions & 0 deletions libcxx/include/__utility/integer_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_s
template<size_t _Np> struct __parity;
template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};

// clang-format off
template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
Expand All @@ -68,6 +69,7 @@ template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<t
template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
// clang-format on

} // namespace detail

Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/bitset
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_BITSET
#define _LIBCPP_BITSET

// clang-format off

/*
bitset synopsis

Expand Down Expand Up @@ -122,6 +124,8 @@ template <size_t N> struct hash<std::bitset<N>>;

*/

// clang-format on

#include <__algorithm/count.h>
#include <__algorithm/fill.h>
#include <__algorithm/find.h>
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_CHRONO
#define _LIBCPP_CHRONO

// clang-format off

/*
chrono synopsis

Expand Down Expand Up @@ -796,6 +798,8 @@ constexpr chrono::year operator ""y(unsigned lo
} // std
*/

// clang-format on

#include <__assert> // all public C++ headers provide the assertion handler
#include <__chrono/calendar.h>
#include <__chrono/convert_to_timespec.h>
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/memory
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_MEMORY
#define _LIBCPP_MEMORY

// clang-format off

/*
memory synopsis

Expand Down Expand Up @@ -914,6 +916,8 @@ template<size_t N, class T>

*/

// clang-format on

#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__memory/addressof.h>
Expand Down
12 changes: 6 additions & 6 deletions libcxx/include/span
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ struct __is_std_span<span<_Tp, _Sz>> : true_type {};

template <class _Range, class _ElementType>
concept __span_compatible_range =
ranges::contiguous_range<_Range> &&
ranges::sized_range<_Range> &&
(ranges::borrowed_range<_Range> || is_const_v<_ElementType>) &&
!__is_std_span<remove_cvref_t<_Range>>::value &&
!__is_std_array<remove_cvref_t<_Range>>::value &&
!is_array_v<remove_cvref_t<_Range>> &&
ranges::contiguous_range<_Range> && //
ranges::sized_range<_Range> && //
(ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && //
!__is_std_span<remove_cvref_t<_Range>>::value && //
!__is_std_array<remove_cvref_t<_Range>>::value && //
!is_array_v<remove_cvref_t<_Range>> && //
is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;

template <class _From, class _To>
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/sstream
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_SSTREAM
#define _LIBCPP_SSTREAM

// clang-format off

/*
sstream synopsis [sstream.syn]

Expand Down Expand Up @@ -266,6 +268,8 @@ typedef basic_stringstream<wchar_t> wstringstream;

*/

// clang-format on

#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/string
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_STRING
#define _LIBCPP_STRING

// clang-format off

/*
string synopsis

Expand Down Expand Up @@ -564,6 +566,8 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );

*/

// clang-format on

#include <__algorithm/max.h>
#include <__algorithm/min.h>
#include <__algorithm/remove.h>
Expand Down
5 changes: 4 additions & 1 deletion libcxx/include/string_view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_STRING_VIEW
#define _LIBCPP_STRING_VIEW

// clang-format off

/*

string_view synopsis
Expand Down Expand Up @@ -199,9 +201,10 @@ namespace std {

} // namespace std


*/

// clang-format on

#include <__algorithm/min.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_TUPLE
#define _LIBCPP_TUPLE

// clang-format off

/*
tuple synopsis

Expand Down Expand Up @@ -201,6 +203,8 @@ template <class... Types>

*/

// clang-format on

#include <__assert> // all public C++ headers provide the assertion handler
#include <__compare/common_comparison_category.h>
#include <__compare/synth_three_way.h>
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/unordered_set
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_UNORDERED_SET
#define _LIBCPP_UNORDERED_SET

// clang-format off

/*

unordered_set synopsis
Expand Down Expand Up @@ -527,6 +529,8 @@ template <class Value, class Hash, class Pred, class Alloc>

*/

// clang-format on

#include <__algorithm/is_permutation.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/vector
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef _LIBCPP_VECTOR
#define _LIBCPP_VECTOR

// clang-format off

/*
vector synopsis

Expand Down Expand Up @@ -301,6 +303,8 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++

*/

// clang-format on

#include <__algorithm/copy.h>
#include <__algorithm/equal.h>
#include <__algorithm/fill_n.h>
Expand Down
2 changes: 2 additions & 0 deletions libcxx/src/locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ extern "C" const int ** __ctype_toupper_loc();
const ctype<char>::mask*
ctype<char>::classic_table() noexcept
{
// clang-format off
static constexpr const ctype<char>::mask builtin_table[table_size] = {
cntrl, cntrl,
cntrl, cntrl,
Expand Down Expand Up @@ -1132,6 +1133,7 @@ ctype<char>::classic_table() noexcept
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
// clang-format on
return builtin_table;
}
#else
Expand Down
2 changes: 2 additions & 0 deletions libcxx/utils/generate_escaped_output_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
#if _LIBCPP_STD_VER >= 23

namespace __escaped_output_table {{
// clang-format off
{content}
// clang-format on
}} // namespace __escaped_output_table

#endif //_LIBCPP_STD_VER >= 23
Expand Down
2 changes: 2 additions & 0 deletions libcxx/utils/generate_extended_grapheme_cluster_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
/// this approach uses less space for the data and is about 4% faster in the
/// following benchmark.
/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
// clang-format off
inline constexpr uint32_t __entries[{size}] = {{
{entries}}};
// clang-format on

/// Returns the extended grapheme cluster bondary property of a code point.
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {{
Expand Down