Skip to content
Merged
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
8 changes: 4 additions & 4 deletions libcxx/include/__functional/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class __value_func<_Rp(_ArgTypes...)> {
}

_LIBCPP_HIDE_FROM_ABI void swap(__value_func& __f) _NOEXCEPT {
if (&__f == this)
if (std::addressof(__f) == this)
return;
if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) {
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
Expand Down Expand Up @@ -550,8 +550,8 @@ struct __policy {
template <typename _Fun>
_LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) {
static constexpr __policy __policy = {
&__large_clone<_Fun>,
&__large_destroy<_Fun>,
std::addressof(__large_clone<_Fun>),
std::addressof(__large_destroy<_Fun>),
false,
# if _LIBCPP_HAS_RTTI
&typeid(typename _Fun::_Target)
Expand Down Expand Up @@ -600,7 +600,7 @@ struct __policy_invoker<_Rp(_ArgTypes...)> {
// Creates an invoker that calls the given instance of __func.
template <typename _Fun>
_LIBCPP_HIDE_FROM_ABI static __policy_invoker __create() {
return __policy_invoker(&__call_impl<_Fun>);
return __policy_invoker(std::addressof(__call_impl<_Fun>));
}

private:
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__numeric/gcd_lcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <__assert>
#include <__bit/countr.h>
#include <__config>
#include <__memory/addressof.h>
#include <__type_traits/common_type.h>
#include <__type_traits/is_integral.h>
#include <__type_traits/is_same.h>
Expand Down Expand Up @@ -115,7 +116,7 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) {
_Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n);
_Rp __val2 = __ct_abs<_Rp, _Up>()(__n);
_Rp __res;
[[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, &__res);
[[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, std::addressof(__res));
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm");
return __res;
}
Expand Down
7 changes: 4 additions & 3 deletions libcxx/include/__numeric/saturation_arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <__assert>
#include <__concepts/arithmetic.h>
#include <__config>
#include <__memory/addressof.h>
#include <__utility/cmp.h>
#include <limits>

Expand All @@ -29,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD

template <__libcpp_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum))
if (_Tp __sum; !__builtin_add_overflow(__x, __y, std::addressof(__sum)))
return __sum;
// Handle overflow
if constexpr (__libcpp_unsigned_integer<_Tp>) {
Expand All @@ -47,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {

template <__libcpp_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub))
if (_Tp __sub; !__builtin_sub_overflow(__x, __y, std::addressof(__sub)))
return __sub;
// Handle overflow
if constexpr (__libcpp_unsigned_integer<_Tp>) {
Expand All @@ -66,7 +67,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {

template <__libcpp_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul))
if (_Tp __mul; !__builtin_mul_overflow(__x, __y, std::addressof(__mul)))
return __mul;
// Handle overflow
if constexpr (__libcpp_unsigned_integer<_Tp>) {
Expand Down
44 changes: 22 additions & 22 deletions libcxx/include/locale
Original file line number Diff line number Diff line change
Expand Up @@ -3114,7 +3114,7 @@ public:
}
_LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __first, const char* __last);

_LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) { return to_bytes(&__wchar, &__wchar + 1); }
_LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) { return to_bytes(std::addressof(__wchar), std::addressof(__wchar) + 1); }
_LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __wptr) {
return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));
}
Expand Down Expand Up @@ -3176,7 +3176,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::from_bytes(const char*
codecvt_base::result __r = codecvt_base::ok;
state_type __st = __cvtstate_;
if (__frm != __frm_end) {
_Elem* __to = &__ws[0];
_Elem* __to = std::addressof(__ws[0]);
_Elem* __to_end = __to + __ws.size();
const char* __frm_nxt;
do {
Expand All @@ -3186,19 +3186,19 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::from_bytes(const char*
if (__frm_nxt == __frm) {
__r = codecvt_base::error;
} else if (__r == codecvt_base::noconv) {
__ws.resize(__to - &__ws[0]);
__ws.resize(__to - std::addressof(__ws[0]));
// This only gets executed if _Elem is char
__ws.append((const _Elem*)__frm, (const _Elem*)__frm_end);
__frm = __frm_nxt;
__r = codecvt_base::ok;
} else if (__r == codecvt_base::ok) {
__ws.resize(__to_nxt - &__ws[0]);
__ws.resize(__to_nxt - std::addressof(__ws[0]));
__frm = __frm_nxt;
} else if (__r == codecvt_base::partial) {
ptrdiff_t __s = __to_nxt - &__ws[0];
ptrdiff_t __s = __to_nxt - std::addressof(__ws[0]);
__ws.resize(2 * __s);
__to = &__ws[0] + __s;
__to_end = &__ws[0] + __ws.size();
__to = std::addressof(__ws[0]) + __s;
__to_end = std::addressof(__ws[0]) + __ws.size();
__frm = __frm_nxt;
}
} while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
Expand All @@ -3224,7 +3224,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem*
codecvt_base::result __r = codecvt_base::ok;
state_type __st = __cvtstate_;
if (__frm != __frm_end) {
char* __to = &__bs[0];
char* __to = std::addressof(__bs[0]);
char* __to_end = __to + __bs.size();
const _Elem* __frm_nxt;
do {
Expand All @@ -3234,41 +3234,41 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem*
if (__frm_nxt == __frm) {
__r = codecvt_base::error;
} else if (__r == codecvt_base::noconv) {
__bs.resize(__to - &__bs[0]);
__bs.resize(__to - std::addressof(__bs[0]));
// This only gets executed if _Elem is char
__bs.append((const char*)__frm, (const char*)__frm_end);
__frm = __frm_nxt;
__r = codecvt_base::ok;
} else if (__r == codecvt_base::ok) {
__bs.resize(__to_nxt - &__bs[0]);
__bs.resize(__to_nxt - std::addressof(__bs[0]));
__frm = __frm_nxt;
} else if (__r == codecvt_base::partial) {
ptrdiff_t __s = __to_nxt - &__bs[0];
ptrdiff_t __s = __to_nxt - std::addressof(__bs[0]);
__bs.resize(2 * __s);
__to = &__bs[0] + __s;
__to_end = &__bs[0] + __bs.size();
__to = std::addressof(__bs[0]) + __s;
__to_end = std::addressof(__bs[0]) + __bs.size();
__frm = __frm_nxt;
}
} while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
}
if (__r == codecvt_base::ok) {
size_t __s = __bs.size();
__bs.resize(__bs.capacity());
char* __to = &__bs[0] + __s;
char* __to = std::addressof(__bs[0]) + __s;
char* __to_end = __to + __bs.size();
do {
char* __to_nxt;
__r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt);
if (__r == codecvt_base::noconv) {
__bs.resize(__to - &__bs[0]);
__bs.resize(__to - std::addressof(__bs[0]));
__r = codecvt_base::ok;
} else if (__r == codecvt_base::ok) {
__bs.resize(__to_nxt - &__bs[0]);
__bs.resize(__to_nxt - std::addressof(__bs[0]));
} else if (__r == codecvt_base::partial) {
ptrdiff_t __sp = __to_nxt - &__bs[0];
ptrdiff_t __sp = __to_nxt - std::addressof(__bs[0]);
__bs.resize(2 * __sp);
__to = &__bs[0] + __sp;
__to_end = &__bs[0] + __bs.size();
__to = std::addressof(__bs[0]) + __sp;
__to_end = std::addressof(__bs[0]) + __bs.size();
}
} while (__r == codecvt_base::partial);
if (__r == codecvt_base::ok)
Expand Down Expand Up @@ -3387,7 +3387,7 @@ typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecv
bool __initial = __read_mode();
char_type __1buf;
if (this->gptr() == 0)
this->setg(&__1buf, &__1buf + 1, &__1buf + 1);
this->setg(std::addressof(__1buf), std::addressof(__1buf) + 1, std::addressof(__1buf) + 1);
const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
int_type __c = traits_type::eof();
if (this->gptr() == this->egptr()) {
Expand Down Expand Up @@ -3429,7 +3429,7 @@ typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecv
}
} else
__c = *this->gptr();
if (this->eback() == &__1buf)
if (this->eback() == std::addressof(__1buf))
this->setg(0, 0, 0);
return __c;
}
Expand Down Expand Up @@ -3465,7 +3465,7 @@ typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecv
char_type* __epb_save = this->epptr();
if (!traits_type::eq_int_type(__c, traits_type::eof())) {
if (this->pptr() == 0)
this->setp(&__1buf, &__1buf + 1);
this->setp(std::addressof(__1buf), std::addressof(__1buf) + 1);
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
}
Expand Down
Loading