Skip to content

Commit 5c717d6

Browse files
authored
[libc++] re-enable clang-tidy in the CI and fix any issues (#102658)
It looks like we've accidentally disabled clang-tidy in the CI. This re-enables it and fixes the issues accumulated while it was disabled.
1 parent 9a227ba commit 5c717d6

File tree

11 files changed

+41
-30
lines changed

11 files changed

+41
-30
lines changed

libcxx/include/__atomic/atomic_ref.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ struct __atomic_ref_base {
219219
_LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); }
220220

221221
protected:
222-
typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment)));
222+
using _Aligned_Tp [[__gnu__::__aligned__(required_alignment)]] = _Tp;
223223
_Aligned_Tp* __ptr_;
224224

225225
_LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {}

libcxx/include/__bit/rotate.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
template <class _Tp>
2727
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT {
2828
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
29-
const int __N = numeric_limits<_Tp>::digits;
30-
int __r = __s % __N;
29+
const int __n = numeric_limits<_Tp>::digits;
30+
int __r = __s % __n;
3131

3232
if (__r == 0)
3333
return __x;
3434

3535
if (__r > 0)
36-
return (__x << __r) | (__x >> (__N - __r));
36+
return (__x << __r) | (__x >> (__n - __r));
3737

38-
return (__x >> -__r) | (__x << (__N + __r));
38+
return (__x >> -__r) | (__x << (__n + __r));
3939
}
4040

4141
template <class _Tp>
4242
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT {
4343
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
44-
const int __N = numeric_limits<_Tp>::digits;
45-
int __r = __s % __N;
44+
const int __n = numeric_limits<_Tp>::digits;
45+
int __r = __s % __n;
4646

4747
if (__r == 0)
4848
return __x;
4949

5050
if (__r > 0)
51-
return (__x >> __r) | (__x << (__N - __r));
51+
return (__x >> __r) | (__x << (__n - __r));
5252

53-
return (__x << -__r) | (__x >> (__N + __r));
53+
return (__x << -__r) | (__x >> (__n + __r));
5454
}
5555

5656
#if _LIBCPP_STD_VER >= 20

libcxx/include/__chrono/zoned_time.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ template <class _TimeZonePtrOrName, class _Duration>
201201
zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest)
202202
-> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
203203

204-
template <class _Duration, class _TimeZonePtrOrName, class TimeZonePtr2>
205-
zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = choose::earliest)
204+
template <class _Duration, class _TimeZonePtrOrName, class _TimeZonePtr2>
205+
zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, _TimeZonePtr2>, choose = choose::earliest)
206206
-> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
207207

208208
using zoned_seconds = zoned_time<seconds>;

libcxx/include/__format/format_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class
132132
: __out_it_(std::move(__out_it)), __args_(__args) {}
133133
# endif
134134

135+
public:
135136
basic_format_context(const basic_format_context&) = delete;
136137
basic_format_context& operator=(const basic_format_context&) = delete;
137138
};

libcxx/include/__memory_resource/polymorphic_allocator.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator {
174174

175175
_LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; }
176176

177-
friend bool operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
177+
_LIBCPP_HIDE_FROM_ABI friend bool
178+
operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
178179
return *__lhs.resource() == *__rhs.resource();
179180
}
180181

181182
# if _LIBCPP_STD_VER <= 17
182183
// This overload is not specified, it was added due to LWG3683.
183-
friend bool operator!=(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
184+
_LIBCPP_HIDE_FROM_ABI friend bool
185+
operator!=(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
184186
return *__lhs.resource() != *__rhs.resource();
185187
}
186188
# endif

libcxx/include/__mutex/unique_lock.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ class _LIBCPP_TEMPLATE_VIS unique_lock {
8484
return *this;
8585
}
8686

87-
void lock();
88-
bool try_lock();
87+
_LIBCPP_HIDE_FROM_ABI void lock();
88+
_LIBCPP_HIDE_FROM_ABI bool try_lock();
8989

9090
template <class _Rep, class _Period>
91-
bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
91+
_LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
9292

9393
template <class _Clock, class _Duration>
94-
bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
94+
_LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
9595

96-
void unlock();
96+
_LIBCPP_HIDE_FROM_ABI void unlock();
9797

9898
_LIBCPP_HIDE_FROM_ABI void swap(unique_lock& __u) _NOEXCEPT {
9999
std::swap(__m_, __u.__m_);
@@ -114,7 +114,7 @@ class _LIBCPP_TEMPLATE_VIS unique_lock {
114114
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
115115

116116
template <class _Mutex>
117-
void unique_lock<_Mutex>::lock() {
117+
_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() {
118118
if (__m_ == nullptr)
119119
__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
120120
if (__owns_)
@@ -124,7 +124,7 @@ void unique_lock<_Mutex>::lock() {
124124
}
125125

126126
template <class _Mutex>
127-
bool unique_lock<_Mutex>::try_lock() {
127+
_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() {
128128
if (__m_ == nullptr)
129129
__throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
130130
if (__owns_)
@@ -135,7 +135,7 @@ bool unique_lock<_Mutex>::try_lock() {
135135

136136
template <class _Mutex>
137137
template <class _Rep, class _Period>
138-
bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
138+
_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
139139
if (__m_ == nullptr)
140140
__throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");
141141
if (__owns_)
@@ -146,7 +146,7 @@ bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __
146146

147147
template <class _Mutex>
148148
template <class _Clock, class _Duration>
149-
bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
149+
_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
150150
if (__m_ == nullptr)
151151
__throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");
152152
if (__owns_)
@@ -156,7 +156,7 @@ bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat
156156
}
157157

158158
template <class _Mutex>
159-
void unique_lock<_Mutex>::unlock() {
159+
_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() {
160160
if (!__owns_)
161161
__throw_system_error(EPERM, "unique_lock::unlock: not locked");
162162
__m_->unlock();

libcxx/include/memory_resource

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ namespace std::pmr {
7272
# include <limits>
7373
# include <mutex>
7474
# include <new>
75-
# include <stdexcept>
7675
# include <tuple>
7776
#endif
7877

libcxx/modules/std/mdspan.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export namespace std {
1515
// [mdspan.extents.dextents], alias template dextents
1616
using std::dextents;
1717

18+
# if _LIBCPP_STD_VER >= 26
19+
// [mdspan.extents.dims]
20+
using std::dims;
21+
# endif // _LIBCPP_STD_VER >= 26
22+
1823
// [mdspan.layout], layout mapping
1924
using std::layout_left;
2025
using std::layout_right;

libcxx/modules/std/new.inc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ export namespace std {
2727

2828
// [ptr.launder], pointer optimization barrier
2929
using std::launder;
30-
#if 0
30+
#if _LIBCPP_STD_VER >= 17
31+
# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
3132
// [hardware.interference], hardware interference size
3233
using std::hardware_constructive_interference_size;
3334
using std::hardware_destructive_interference_size;
34-
#endif
35+
# endif
36+
#endif // _LIBCPP_STD_VER >= 17
3537
} // namespace std
3638

3739
export {

libcxx/test/tools/clang_tidy_checks/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ endif()
7171
# Note it has not been tested whether version 11 works.
7272
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.cpp" "
7373
#include <version>
74-
#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 12
74+
#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 11
7575
# error The libstdc++ version is too old.
7676
#endif
7777
int main(){}
@@ -83,7 +83,7 @@ try_compile(HAS_NEWER_STANDARD_LIBRARY
8383

8484
if(NOT HAS_NEWER_STANDARD_LIBRARY)
8585
message(STATUS "Clang-tidy tests are disabled due to using "
86-
"stdlibc++ older than version 12")
86+
"stdlibc++ older than version 11")
8787
return()
8888
endif()
8989
message(STATUS "Clang-tidy tests are enabled.")

0 commit comments

Comments
 (0)