[llvm-branch-commits] [libcxx] [llvm] [libc++][C++03] Use `__cxx03/` headers in C++03 mode (PR #109002)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Sep 17 09:01:04 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff e888ef35e747287df8b3f79778f40a001e445735 4d02649d3a1765a02bf41e8e04a585856d85b8d4 --extensions ,h -- libcxx/include/__configuration/cxx03.h libcxx/include/__config libcxx/include/__cxx03/__config libcxx/include/algorithm libcxx/include/any libcxx/include/array libcxx/include/atomic libcxx/include/barrier libcxx/include/bit libcxx/include/bitset libcxx/include/cassert libcxx/include/ccomplex libcxx/include/cctype libcxx/include/cerrno libcxx/include/cfenv libcxx/include/cfloat libcxx/include/charconv libcxx/include/chrono libcxx/include/cinttypes libcxx/include/ciso646 libcxx/include/climits libcxx/include/clocale libcxx/include/cmath libcxx/include/codecvt libcxx/include/compare libcxx/include/complex libcxx/include/complex.h libcxx/include/concepts libcxx/include/condition_variable libcxx/include/coroutine libcxx/include/csetjmp libcxx/include/csignal libcxx/include/cstdarg libcxx/include/cstdbool libcxx/include/cstddef libcxx/include/cstdint libcxx/include/cstdio libcxx/include/cstdlib libcxx/include/cstring libcxx/include/ctgmath libcxx/include/ctime libcxx/include/ctype.h libcxx/include/cuchar libcxx/include/cwchar libcxx/include/cwctype libcxx/include/deque libcxx/include/errno.h libcxx/include/exception libcxx/include/execution libcxx/include/expected libcxx/include/fenv.h libcxx/include/filesystem libcxx/include/float.h libcxx/include/format libcxx/include/forward_list libcxx/include/fstream libcxx/include/functional libcxx/include/future libcxx/include/initializer_list libcxx/include/inttypes.h libcxx/include/iomanip libcxx/include/ios libcxx/include/iosfwd libcxx/include/iostream libcxx/include/istream libcxx/include/iterator libcxx/include/latch libcxx/include/limits libcxx/include/list libcxx/include/locale libcxx/include/locale.h libcxx/include/map libcxx/include/math.h libcxx/include/mdspan libcxx/include/memory libcxx/include/memory_resource libcxx/include/mutex libcxx/include/new libcxx/include/numbers libcxx/include/numeric libcxx/include/optional libcxx/include/ostream libcxx/include/print libcxx/include/queue libcxx/include/random libcxx/include/ranges libcxx/include/ratio libcxx/include/regex libcxx/include/scoped_allocator libcxx/include/semaphore libcxx/include/set libcxx/include/shared_mutex libcxx/include/source_location libcxx/include/span libcxx/include/sstream libcxx/include/stack libcxx/include/stdatomic.h libcxx/include/stdbool.h libcxx/include/stddef.h libcxx/include/stdexcept libcxx/include/stdint.h libcxx/include/stdio.h libcxx/include/stdlib.h libcxx/include/stop_token libcxx/include/streambuf libcxx/include/string libcxx/include/string.h libcxx/include/string_view libcxx/include/strstream libcxx/include/syncstream libcxx/include/system_error libcxx/include/tgmath.h libcxx/include/thread libcxx/include/tuple libcxx/include/type_traits libcxx/include/typeindex libcxx/include/typeinfo libcxx/include/uchar.h libcxx/include/unordered_map libcxx/include/unordered_set libcxx/include/utility libcxx/include/valarray libcxx/include/variant libcxx/include/vector libcxx/include/wchar.h libcxx/include/wctype.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__configuration/cxx03.h b/libcxx/include/__configuration/cxx03.h
index 606de3d2c7..1d4d9bc008 100644
--- a/libcxx/include/__configuration/cxx03.h
+++ b/libcxx/include/__configuration/cxx03.h
@@ -14,8 +14,8 @@
 #endif
 
 // NOLINTNEXTLINE(libcpp-cpp-version-check)
-#  if __cplusplus < 201103L
-#    define _LIBCPP_CXX03_LANG
-#  endif
+#if __cplusplus < 201103L
+#  define _LIBCPP_CXX03_LANG
+#endif
 
 #endif // _LIBCPP___CONFIGURATION_CXX03_H
diff --git a/libcxx/include/bitset b/libcxx/include/bitset
index 82b226676b..9d4b97a7dc 100644
--- a/libcxx/include/bitset
+++ b/libcxx/include/bitset
@@ -296,7 +296,7 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long
 #  endif
 {
 #  ifdef _LIBCPP_CXX03_LANG
-  __init(__v, integral_constant < bool, sizeof(unsigned long long) == sizeof(__storage_type) > ());
+  __init(__v, integral_constant< bool, sizeof(unsigned long long) == sizeof(__storage_type) >());
 #  endif
 }
 
diff --git a/libcxx/include/ccomplex b/libcxx/include/ccomplex
index ae920658d7..c27c171279 100644
--- a/libcxx/include/ccomplex
+++ b/libcxx/include/ccomplex
@@ -22,11 +22,11 @@
 #if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_CXX03_USE_MAIN_HEADERS)
 #  include <__cxx03/ccomplex>
 #else
-#include <complex>
+#  include <complex>
 
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
+#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#    pragma GCC system_header
+#  endif
 #endif // _LIBCPP_CXX03_LANG
 
 #endif // _LIBCPP_CCOMPLEX
diff --git a/libcxx/include/codecvt b/libcxx/include/codecvt
index 84146dba56..7077297f6a 100644
--- a/libcxx/include/codecvt
+++ b/libcxx/include/codecvt
@@ -442,8 +442,7 @@ class _LIBCPP_TEMPLATE_VIS
 _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> {
 public:
   _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0)
-      : __codecvt_utf16 < _Elem,
-  _Mode & little_endian > (__refs, _Maxcode, _Mode) {}
+      : __codecvt_utf16< _Elem, _Mode & little_endian >(__refs, _Maxcode, _Mode) {}
 
   _LIBCPP_HIDE_FROM_ABI ~codecvt_utf16() {}
 };
diff --git a/libcxx/include/condition_variable b/libcxx/include/condition_variable
index 89e8e9ab81..9f978e52b7 100644
--- a/libcxx/include/condition_variable
+++ b/libcxx/include/condition_variable
@@ -197,16 +197,12 @@ public:
 inline condition_variable_any::condition_variable_any() : __mut_(make_shared<mutex>()) {}
 
 inline void condition_variable_any::notify_one() _NOEXCEPT {
-  {
-    lock_guard<mutex> __lx(*__mut_);
-  }
+  { lock_guard<mutex> __lx(*__mut_); }
   __cv_.notify_one();
 }
 
 inline void condition_variable_any::notify_all() _NOEXCEPT {
-  {
-    lock_guard<mutex> __lx(*__mut_);
-  }
+  { lock_guard<mutex> __lx(*__mut_); }
   __cv_.notify_all();
 }
 
diff --git a/libcxx/include/map b/libcxx/include/map
index 3e49a040ea..6e8ea6bdee 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1483,8 +1483,9 @@ template <class _Key,
           class _Allocator = allocator<pair<const _Key, _Tp>>,
           class            = enable_if_t<!__is_allocator<_Compare>::value, void>,
           class            = enable_if_t<__is_allocator<_Allocator>::value, void>>
-map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
-    -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
+map(initializer_list<pair<_Key, _Tp>>,
+    _Compare   = _Compare(),
+    _Allocator = _Allocator()) -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
 
 template <class _InputIterator,
           class _Allocator,
@@ -1503,8 +1504,8 @@ map(from_range_t, _Range&&, _Allocator)
 #    endif
 
 template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
-map(initializer_list<pair<_Key, _Tp>>, _Allocator)
-    -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
+map(initializer_list<pair<_Key, _Tp>>,
+    _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
 #  endif
 
 #  ifndef _LIBCPP_CXX03_LANG
@@ -2061,8 +2062,9 @@ template <class _Key,
           class _Allocator = allocator<pair<const _Key, _Tp>>,
           class            = enable_if_t<!__is_allocator<_Compare>::value, void>,
           class            = enable_if_t<__is_allocator<_Allocator>::value, void>>
-multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
-    -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
+multimap(initializer_list<pair<_Key, _Tp>>,
+         _Compare   = _Compare(),
+         _Allocator = _Allocator()) -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
 
 template <class _InputIterator,
           class _Allocator,
@@ -2081,8 +2083,8 @@ multimap(from_range_t, _Range&&, _Allocator)
 #    endif
 
 template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
-multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
-    -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
+multimap(initializer_list<pair<_Key, _Tp>>,
+         _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
 #  endif
 
 #  ifndef _LIBCPP_CXX03_LANG
diff --git a/libcxx/include/queue b/libcxx/include/queue
index ff38655aed..c6636936f6 100644
--- a/libcxx/include/queue
+++ b/libcxx/include/queue
@@ -454,12 +454,14 @@ template <class _InputIterator,
           class _Alloc,
           __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
           __enable_if_t<__is_allocator<_Alloc>::value, int>                        = 0>
-queue(_InputIterator, _InputIterator, _Alloc)
-    -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
+queue(_InputIterator,
+      _InputIterator,
+      _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
 
 template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
-queue(from_range_t, _Range&&, _Alloc)
-    -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
+queue(from_range_t,
+      _Range&&,
+      _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
 #  endif
 
 template <class _Tp, class _Container>
diff --git a/libcxx/include/set b/libcxx/include/set
index 98812986cf..98f1500e4c 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -936,13 +936,15 @@ template <class _InputIterator,
           class _Allocator,
           class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,
           class = enable_if_t<__is_allocator<_Allocator>::value, void>>
-set(_InputIterator, _InputIterator, _Allocator)
-    -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;
+set(_InputIterator,
+    _InputIterator,
+    _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;
 
 #    if _LIBCPP_STD_VER >= 23
 template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
-set(from_range_t, _Range&&, _Allocator)
-    -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
+set(from_range_t,
+    _Range&&,
+    _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
 #    endif
 
 template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
@@ -1385,8 +1387,9 @@ template <class _Key,
           class _Allocator = allocator<_Key>,
           class            = enable_if_t<__is_allocator<_Allocator>::value, void>,
           class            = enable_if_t<!__is_allocator<_Compare>::value, void>>
-multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
-    -> multiset<_Key, _Compare, _Allocator>;
+multiset(initializer_list<_Key>,
+         _Compare   = _Compare(),
+         _Allocator = _Allocator()) -> multiset<_Key, _Compare, _Allocator>;
 
 template <class _InputIterator,
           class _Allocator,
@@ -1397,8 +1400,9 @@ multiset(_InputIterator, _InputIterator, _Allocator)
 
 #    if _LIBCPP_STD_VER >= 23
 template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
-multiset(from_range_t, _Range&&, _Allocator)
-    -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
+multiset(from_range_t,
+         _Range&&,
+         _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
 #    endif
 
 template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
diff --git a/libcxx/include/span b/libcxx/include/span
index e7480f027d..1cc3226370 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -331,8 +331,8 @@ public:
   }
 
   template <size_t _Offset, size_t _Count = dynamic_extent>
-  _LIBCPP_HIDE_FROM_ABI constexpr auto subspan() const noexcept
-      -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> {
+  _LIBCPP_HIDE_FROM_ABI constexpr auto
+  subspan() const noexcept -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> {
     static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range");
     static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset,
                   "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range");
diff --git a/libcxx/include/stack b/libcxx/include/stack
index 863abd314f..523a07f300 100644
--- a/libcxx/include/stack
+++ b/libcxx/include/stack
@@ -309,12 +309,14 @@ template <class _InputIterator,
           class _Alloc,
           __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
           __enable_if_t<__is_allocator<_Alloc>::value, int>                        = 0>
-stack(_InputIterator, _InputIterator, _Alloc)
-    -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
+stack(_InputIterator,
+      _InputIterator,
+      _Alloc) -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
 
 template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
-stack(from_range_t, _Range&&, _Alloc)
-    -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
+stack(from_range_t,
+      _Range&&,
+      _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
 
 #  endif
 
diff --git a/libcxx/include/string b/libcxx/include/string
index 0b51867f54..7ac8fd7ec7 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -2294,8 +2294,8 @@ template <class _CharT,
           class _Traits,
           class _Allocator = allocator<_CharT>,
           class            = enable_if_t<__is_allocator<_Allocator>::value> >
-explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
-    -> basic_string<_CharT, _Traits, _Allocator>;
+explicit basic_string(basic_string_view<_CharT, _Traits>,
+                      const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>;
 
 template <class _CharT,
           class _Traits,
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 30a4959c69..1d5fd76d53 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -2248,12 +2248,12 @@ template <class _Key,
           class            = enable_if_t<!is_integral<_Hash>::value>,
           class            = enable_if_t<!__is_allocator<_Pred>::value>,
           class            = enable_if_t<__is_allocator<_Allocator>::value>>
-unordered_multimap(initializer_list<pair<_Key, _Tp>>,
-                   typename allocator_traits<_Allocator>::size_type = 0,
-                   _Hash                                            = _Hash(),
-                   _Pred                                            = _Pred(),
-                   _Allocator                                       = _Allocator())
-    -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
+unordered_multimap(
+    initializer_list<pair<_Key, _Tp>>,
+    typename allocator_traits<_Allocator>::size_type = 0,
+    _Hash                                            = _Hash(),
+    _Pred                                            = _Pred(),
+    _Allocator = _Allocator()) -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
 
 template <class _InputIterator,
           class _Allocator,
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index e1d1e22b82..22b2551ecc 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -939,13 +939,13 @@ template <ranges::input_range _Range,
           class            = enable_if_t<!is_integral<_Hash>::value>,
           class            = enable_if_t<!__is_allocator<_Pred>::value>,
           class            = enable_if_t<__is_allocator<_Allocator>::value>>
-unordered_set(from_range_t,
-              _Range&&,
-              typename allocator_traits<_Allocator>::size_type = 0,
-              _Hash                                            = _Hash(),
-              _Pred                                            = _Pred(),
-              _Allocator                                       = _Allocator())
-    -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
+unordered_set(
+    from_range_t,
+    _Range&&,
+    typename allocator_traits<_Allocator>::size_type = 0,
+    _Hash                                            = _Hash(),
+    _Pred                                            = _Pred(),
+    _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
 #    endif
 
 template <class _Tp,
diff --git a/libcxx/include/variant b/libcxx/include/variant
index fa7629152d..7aaa08e763 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -855,7 +855,8 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
 _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
     _Trait::_Available,
     _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) noexcept(
-        __all<is_nothrow_move_constructible_v<_Types>...>::value) : __move_constructor(__valueless_t{}) {
+        __all<is_nothrow_move_constructible_v<_Types>...>::value)
+    : __move_constructor(__valueless_t{}) {
       this->__generic_construct(*this, std::move(__that));
     } _LIBCPP_EAT_SEMICOLON);
 
@@ -891,9 +892,8 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR(
 
 _LIBCPP_VARIANT_COPY_CONSTRUCTOR(
     _Trait::_Available,
-    _LIBCPP_HIDE_FROM_ABI
-    _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that) : __copy_constructor(
-        __valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON);
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that)
+    : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON);
 
 _LIBCPP_VARIANT_COPY_CONSTRUCTOR(
     _Trait::_Unavailable,
@@ -1584,8 +1584,8 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {
 
 template <class... _Types>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto
-swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs)))
-    -> decltype(__lhs.swap(__rhs)) {
+swap(variant<_Types...>& __lhs,
+     variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) -> decltype(__lhs.swap(__rhs)) {
   return __lhs.swap(__rhs);
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/109002


More information about the llvm-branch-commits mailing list