[libcxx-commits] [libcxx] [libc++][math] Add `constexpr` to `copysign` functions (PR #216285)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Aug 16 16:38:40 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions ,cpp,h -- libcxx/include/__math/copysign.h libcxx/include/cmath libcxx/include/math.h libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__math/copysign.h b/libcxx/include/__math/copysign.h
index e87097ba8..c100c0365 100644
--- a/libcxx/include/__math/copysign.h
+++ b/libcxx/include/__math/copysign.h
@@ -29,8 +29,10 @@ copysign(float __x, float __y) _NOEXCEPT {
return ::__builtin_copysignf(__x, __y);
}
-[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
-double copysign(double __x, double __y) _NOEXCEPT { return __builtin_copysign(__x, __y); }
+[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI double
+copysign(double __x, double __y) _NOEXCEPT {
+ return __builtin_copysign(__x, __y);
+}
[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI long double
copysign(long double __x, long double __y) _NOEXCEPT {
@@ -39,8 +41,8 @@ copysign(long double __x, long double __y) _NOEXCEPT {
template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2>
- copysign(_A1 __x, _A2 __y) _NOEXCEPT {
- return ::__builtin_copysign(__x, __y);
+copysign(_A1 __x, _A2 __y) _NOEXCEPT {
+ return ::__builtin_copysign(__x, __y);
}
} // namespace __math
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index 2ee9f078a..dd53594ea 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -424,17 +424,17 @@ using ::atanhf _LIBCPP_USING_IF_EXISTS;
using ::cbrt _LIBCPP_USING_IF_EXISTS;
using ::cbrtf _LIBCPP_USING_IF_EXISTS;
-#if _LIBCPP_STD_VER >= 23 && __has_constexpr_builtin(__builtin_copysign)
+# if _LIBCPP_STD_VER >= 23 && __has_constexpr_builtin(__builtin_copysign)
_LIBCPP_HIDE_FROM_ABI constexpr double copysign(double __x, double __y) _NOEXCEPT {
return __builtin_copysign(__x, __y);
}
_LIBCPP_HIDE_FROM_ABI constexpr float copysignf(float __x, float __y) _NOEXCEPT {
return __builtin_copysignf(__x, __y);
}
-#else
+# else
using ::copysign _LIBCPP_USING_IF_EXISTS;
using ::copysignf _LIBCPP_USING_IF_EXISTS;
-#endif
+# endif
using ::erf _LIBCPP_USING_IF_EXISTS;
using ::erff _LIBCPP_USING_IF_EXISTS;
@@ -527,13 +527,13 @@ using ::asinhl _LIBCPP_USING_IF_EXISTS;
using ::atanhl _LIBCPP_USING_IF_EXISTS;
using ::cbrtl _LIBCPP_USING_IF_EXISTS;
-#if _LIBCPP_STD_VER >= 23 && __has_constexpr_builtin(__builtin_copysignl)
+# if _LIBCPP_STD_VER >= 23 && __has_constexpr_builtin(__builtin_copysignl)
_LIBCPP_HIDE_FROM_ABI constexpr long double copysignl(long double __x, long double __y) _NOEXCEPT {
return __builtin_copysignl(__x, __y);
}
-#else
+# else
using ::copysignl _LIBCPP_USING_IF_EXISTS;
-#endif
+# endif
using ::erfl _LIBCPP_USING_IF_EXISTS;
using ::erfcl _LIBCPP_USING_IF_EXISTS;
``````````
</details>
https://github.com/llvm/llvm-project/pull/216285
More information about the libcxx-commits
mailing list