Skip to content

Commit

Permalink
[libc++] Fix clang-tidy issues and re-enable it in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
philnik777 committed Aug 9, 2024
1 parent edf45e4 commit b3a0798
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 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
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
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 b3a0798

Please sign in to comment.