Skip to content

Commit

Permalink
[libc++] re-enable clang-tidy in the CI and fix any issues (llvm#102658)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
philnik777 authored and bwendling committed Aug 15, 2024
1 parent 666932a commit 956c2bd
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion libcxx/include/__atomic/atomic_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ struct __atomic_ref_base {
_LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); }

protected:
typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment)));
using _Aligned_Tp [[__gnu__::__aligned__(required_alignment)]] = _Tp;
_Aligned_Tp* __ptr_;

_LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {}
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/__bit/rotate.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT {
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
const int __N = numeric_limits<_Tp>::digits;
int __r = __s % __N;
const int __n = numeric_limits<_Tp>::digits;
int __r = __s % __n;

if (__r == 0)
return __x;

if (__r > 0)
return (__x << __r) | (__x >> (__N - __r));
return (__x << __r) | (__x >> (__n - __r));

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

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

if (__r == 0)
return __x;

if (__r > 0)
return (__x >> __r) | (__x << (__N - __r));
return (__x >> __r) | (__x << (__n - __r));

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

#if _LIBCPP_STD_VER >= 20
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__chrono/zoned_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ template <class _TimeZonePtrOrName, class _Duration>
zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest)
-> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;

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

using zoned_seconds = zoned_time<seconds>;
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__format/format_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class
: __out_it_(std::move(__out_it)), __args_(__args) {}
# endif

public:
basic_format_context(const basic_format_context&) = delete;
basic_format_context& operator=(const basic_format_context&) = delete;
};
Expand Down
6 changes: 4 additions & 2 deletions libcxx/include/__memory_resource/polymorphic_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator {

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

friend bool operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
_LIBCPP_HIDE_FROM_ABI friend bool
operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
return *__lhs.resource() == *__rhs.resource();
}

# if _LIBCPP_STD_VER <= 17
// This overload is not specified, it was added due to LWG3683.
friend bool operator!=(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
_LIBCPP_HIDE_FROM_ABI friend bool
operator!=(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
return *__lhs.resource() != *__rhs.resource();
}
# endif
Expand Down
20 changes: 10 additions & 10 deletions libcxx/include/__mutex/unique_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ class _LIBCPP_TEMPLATE_VIS unique_lock {
return *this;
}

void lock();
bool try_lock();
_LIBCPP_HIDE_FROM_ABI void lock();
_LIBCPP_HIDE_FROM_ABI bool try_lock();

template <class _Rep, class _Period>
bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
_LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);

template <class _Clock, class _Duration>
bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
_LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);

void unlock();
_LIBCPP_HIDE_FROM_ABI void unlock();

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

template <class _Mutex>
void unique_lock<_Mutex>::lock() {
_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() {
if (__m_ == nullptr)
__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
if (__owns_)
Expand All @@ -124,7 +124,7 @@ void unique_lock<_Mutex>::lock() {
}

template <class _Mutex>
bool unique_lock<_Mutex>::try_lock() {
_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() {
if (__m_ == nullptr)
__throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
if (__owns_)
Expand All @@ -135,7 +135,7 @@ bool unique_lock<_Mutex>::try_lock() {

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

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

template <class _Mutex>
void unique_lock<_Mutex>::unlock() {
_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() {
if (!__owns_)
__throw_system_error(EPERM, "unique_lock::unlock: not locked");
__m_->unlock();
Expand Down
1 change: 0 additions & 1 deletion libcxx/include/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ namespace std::pmr {
# include <limits>
# include <mutex>
# include <new>
# include <stdexcept>
# include <tuple>
#endif

Expand Down
5 changes: 5 additions & 0 deletions libcxx/modules/std/mdspan.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export namespace std {
// [mdspan.extents.dextents], alias template dextents
using std::dextents;

# if _LIBCPP_STD_VER >= 26
// [mdspan.extents.dims]
using std::dims;
# endif // _LIBCPP_STD_VER >= 26

// [mdspan.layout], layout mapping
using std::layout_left;
using std::layout_right;
Expand Down
6 changes: 4 additions & 2 deletions libcxx/modules/std/new.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export namespace std {

// [ptr.launder], pointer optimization barrier
using std::launder;
#if 0
#if _LIBCPP_STD_VER >= 17
# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
// [hardware.interference], hardware interference size
using std::hardware_constructive_interference_size;
using std::hardware_destructive_interference_size;
#endif
# endif
#endif // _LIBCPP_STD_VER >= 17
} // namespace std

export {
Expand Down
4 changes: 2 additions & 2 deletions libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ endif()
# Note it has not been tested whether version 11 works.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.cpp" "
#include <version>
#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 12
#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 11
# error The libstdc++ version is too old.
#endif
int main(){}
Expand All @@ -83,7 +83,7 @@ try_compile(HAS_NEWER_STANDARD_LIBRARY

if(NOT HAS_NEWER_STANDARD_LIBRARY)
message(STATUS "Clang-tidy tests are disabled due to using "
"stdlibc++ older than version 12")
"stdlibc++ older than version 11")
return()
endif()
message(STATUS "Clang-tidy tests are enabled.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ header_exportable_declarations::header_exportable_declarations(

list = Options.get("ExtraDeclarations");
if (list)
for (auto decl : std::views::split(*list, ' '))
std::cout << "using ::" << std::string_view{decl.data(), decl.size()} << ";\n";
for (auto decl : std::views::split(*list, ' ')) {
auto common = decl | std::views::common;
std::cout << "using ::" << std::string{common.begin(), common.end()} << ";\n";
}
}

header_exportable_declarations::~header_exportable_declarations() {
Expand Down

0 comments on commit 956c2bd

Please sign in to comment.