Skip to content
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

[libcxx] responds to Clang Tidy feedback #97556

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions libcxx/include/__functional/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base
# ifdef _LIBCPP_HAS_OBJC_ARC
: __f_(__f)
# else
: __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
: __f_(reinterpret_cast<__block_type>(__f ? std::__function::_Block_copy(__f) : nullptr))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: __f_(reinterpret_cast<__block_type>(__f ? std::__function::_Block_copy(__f) : nullptr))
: __f_(reinterpret_cast<__block_type>(__f ? __function::_Block_copy(__f) : nullptr))

# endif
{
}
Expand All @@ -765,7 +765,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base
# ifdef _LIBCPP_HAS_OBJC_ARC
: __f_(__f)
# else
: __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
: __f_(reinterpret_cast<__block_type>(__f ? std::__function::_Block_copy(__f) : nullptr))
# endif
{
}
Expand All @@ -786,7 +786,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base
_LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {
# ifndef _LIBCPP_HAS_OBJC_ARC
if (__f_)
_Block_release(__f_);
std::__function::_Block_release(__f_);
# endif
__f_ = 0;
}
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/__thread/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ class _LIBCPP_TEMPLATE_VIS __thread_id {

static _LIBCPP_HIDE_FROM_ABI bool
__lt_impl(__thread_id __x, __thread_id __y) _NOEXCEPT { // id==0 is always less than any other thread_id
if (__x.__id_ == 0)
return __y.__id_ != 0;
if (__y.__id_ == 0)
if (__x.__id_ == nullptr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like __x.__id_ isn't a pointer on other platforms. I guess we just have to disable the check for this file.

return __y.__id_ != nullptr;
if (__y.__id_ == nullptr)
return false;
return __libcpp_thread_id_less(__x.__id_, __y.__id_);
}

public:
_LIBCPP_HIDE_FROM_ABI __thread_id() _NOEXCEPT : __id_(0) {}
_LIBCPP_HIDE_FROM_ABI __thread_id() _NOEXCEPT : __id_(nullptr) {}

_LIBCPP_HIDE_FROM_ABI void __reset() { __id_ = 0; }
_LIBCPP_HIDE_FROM_ABI void __reset() { __id_ = nullptr; }

friend _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT;
# if _LIBCPP_STD_VER <= 17
Expand All @@ -77,9 +77,9 @@ class _LIBCPP_TEMPLATE_VIS __thread_id {

inline _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT {
// Don't pass id==0 to underlying routines
if (__x.__id_ == 0)
return __y.__id_ == 0;
if (__y.__id_ == 0)
if (__x.__id_ == nullptr)
return __y.__id_ == nullptr;
if (__y.__id_ == nullptr)
return false;
return __libcpp_thread_id_equal(__x.__id_, __y.__id_);
}
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__thread/support/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __l
}

inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) {
return __libcpp_thread_get_id(__t) == 0;
return __libcpp_thread_get_id(__t) == nullptr;
}

inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) {
Expand Down
Loading