[libcxx-commits] [libcxx] [libc++][NFC] Use std::isinf in non-constexpr functions (PR #107690)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 8 02:46:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/107690.diff
1 Files Affected:
- (modified) libcxx/include/complex (+28-28)
``````````diff
diff --git a/libcxx/include/complex b/libcxx/include/complex
index 94fd8ee347dffb..4030d96b003d56 100644
--- a/libcxx/include/complex
+++ b/libcxx/include/complex
@@ -997,14 +997,14 @@ conj(_Tp __re) {
template <class _Tp>
inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) {
complex<_Tp> __r = __c;
- if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag()))
+ if (std::isinf(__c.real()) || std::isinf(__c.imag()))
__r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));
return __r;
}
template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) {
- if (std::__constexpr_isinf(__re))
+ if (std::isinf(__re))
__re = std::abs(__re);
return complex<_Tp>(__re);
}
@@ -1022,12 +1022,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta =
if (std::isnan(__rho) || std::signbit(__rho))
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
if (std::isnan(__theta)) {
- if (std::__constexpr_isinf(__rho))
+ if (std::isinf(__rho))
return complex<_Tp>(__rho, __theta);
return complex<_Tp>(__theta, __theta);
}
- if (std::__constexpr_isinf(__theta)) {
- if (std::__constexpr_isinf(__rho))
+ if (std::isinf(__theta)) {
+ if (std::isinf(__rho))
return complex<_Tp>(__rho, _Tp(NAN));
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
}
@@ -1058,9 +1058,9 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) {
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag());
- if (std::__constexpr_isinf(__x.real())) {
+ if (std::isinf(__x.real())) {
if (__x.real() > _Tp(0))
return complex<_Tp>(__x.real(), std::isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
return complex<_Tp>(std::isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
@@ -1076,12 +1076,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) {
if (__i == 0) {
return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag()));
}
- if (std::__constexpr_isinf(__x.real())) {
+ if (std::isinf(__x.real())) {
if (__x.real() < _Tp(0)) {
if (!std::isfinite(__i))
__i = _Tp(1);
} else if (__i == 0 || !std::isfinite(__i)) {
- if (std::__constexpr_isinf(__i))
+ if (std::isinf(__i))
__i = _Tp(NAN);
return complex<_Tp>(__x.real(), __i);
}
@@ -1128,21 +1128,21 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) {
const _Tp __pi(atan2(+0., -0.));
- if (std::__constexpr_isinf(__x.real())) {
+ if (std::isinf(__x.real())) {
if (std::isnan(__x.imag()))
return __x;
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
}
if (std::isnan(__x.real())) {
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
if (__x.imag() == 0)
return __x;
return complex<_Tp>(__x.real(), __x.real());
}
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));
return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
@@ -1153,10 +1153,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {
const _Tp __pi(atan2(+0., -0.));
- if (std::__constexpr_isinf(__x.real())) {
+ if (std::isinf(__x.real())) {
if (std::isnan(__x.imag()))
return complex<_Tp>(std::abs(__x.real()), __x.imag());
- if (std::__constexpr_isinf(__x.imag())) {
+ if (std::isinf(__x.imag())) {
if (__x.real() > 0)
return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
else
@@ -1167,11 +1167,11 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {
return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
}
if (std::isnan(__x.real())) {
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(std::abs(__x.imag()), __x.real());
return complex<_Tp>(__x.real(), __x.real());
}
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi / _Tp(2), __x.imag()));
complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));
@@ -1182,18 +1182,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) {
const _Tp __pi(atan2(+0., -0.));
- if (std::__constexpr_isinf(__x.imag())) {
+ if (std::isinf(__x.imag())) {
return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
}
if (std::isnan(__x.imag())) {
- if (std::__constexpr_isinf(__x.real()) || __x.real() == 0)
+ if (std::isinf(__x.real()) || __x.real() == 0)
return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());
return complex<_Tp>(__x.imag(), __x.imag());
}
if (std::isnan(__x.real())) {
return complex<_Tp>(__x.real(), __x.real());
}
- if (std::__constexpr_isinf(__x.real())) {
+ if (std::isinf(__x.real())) {
return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
}
if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) {
@@ -1207,7 +1207,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) {
- if (std::__constexpr_isinf(__x.real()) && !std::isfinite(__x.imag()))
+ if (std::isinf(__x.real()) && !std::isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
if (__x.real() == 0 && !std::isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
@@ -1220,7 +1220,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) {
- if (std::__constexpr_isinf(__x.real()) && !std::isfinite(__x.imag()))
+ if (std::isinf(__x.real()) && !std::isfinite(__x.imag()))
return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));
if (__x.real() == 0 && !std::isfinite(__x.imag()))
return complex<_Tp>(_Tp(NAN), __x.real());
@@ -1235,7 +1235,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) {
- if (std::__constexpr_isinf(__x.real())) {
+ if (std::isinf(__x.real())) {
if (!std::isfinite(__x.imag()))
return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));
return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));
@@ -1246,7 +1246,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) {
_Tp __2i(_Tp(2) * __x.imag());
_Tp __d(std::cosh(__2r) + std::cos(__2i));
_Tp __2rsh(std::sinh(__2r));
- if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d))
+ if (std::isinf(__2rsh) && std::isinf(__d))
return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
return complex<_Tp>(__2rsh / __d, std::sin(__2i) / __d);
}
@@ -1264,10 +1264,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) {
const _Tp __pi(atan2(+0., -0.));
- if (std::__constexpr_isinf(__x.real())) {
+ if (std::isinf(__x.real())) {
if (std::isnan(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
- if (std::__constexpr_isinf(__x.imag())) {
+ if (std::isinf(__x.imag())) {
if (__x.real() < _Tp(0))
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
@@ -1277,11 +1277,11 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) {
return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());
}
if (std::isnan(__x.real())) {
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(__x.real(), -__x.imag());
return complex<_Tp>(__x.real(), __x.real());
}
- if (std::__constexpr_isinf(__x.imag()))
+ if (std::isinf(__x.imag()))
return complex<_Tp>(__pi / _Tp(2), -__x.imag());
if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag())))
return complex<_Tp>(__pi / _Tp(2), -__x.imag());
``````````
</details>
https://github.com/llvm/llvm-project/pull/107690
More information about the libcxx-commits
mailing list