[libcxx-commits] [libcxx] [libc++][math] Adding `[[nodicard]]` (PR #171763)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 10 21:14:28 PST 2025


https://github.com/H-G-Hristov created https://github.com/llvm/llvm-project/pull/171763

`[[nodiscard]]` should be applied to functions where discarding the return value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.htm
- https://wg21.link/c.math

>From 2f3f54a145cee73b0307f5837fe9926d28e6e957 Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Mon, 24 Nov 2025 18:37:03 +0200
Subject: [PATCH] [libc++][math] Adding `[[nodicard]]`

`[[nodiscard]]`` should be applied to functions where discarding the return value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.htm
- https://wg21.link/c.math
---
 libcxx/include/__math/error_functions.h       |  18 +-
 libcxx/include/__math/exponential_functions.h |  80 +++++---
 libcxx/include/__math/fdim.h                  |  10 +-
 libcxx/include/__math/fma.h                   |   9 +-
 libcxx/include/__math/gamma.h                 |  20 +-
 libcxx/include/__math/hyperbolic_functions.h  |  30 +--
 libcxx/include/__math/hypot.h                 |  22 ++-
 .../__math/inverse_hyperbolic_functions.h     |  24 +--
 .../__math/inverse_trigonometric_functions.h  |  40 ++--
 .../include/__math/trigonometric_functions.h  |  30 +--
 libcxx/include/cmath                          |  10 +-
 .../diagnostics/cmath.nodiscard.verify.cpp    | 184 ++++++++++++++++++
 12 files changed, 358 insertions(+), 119 deletions(-)

diff --git a/libcxx/include/__math/error_functions.h b/libcxx/include/__math/error_functions.h
index 6b528bb290001..92cc05b433a7d 100644
--- a/libcxx/include/__math/error_functions.h
+++ b/libcxx/include/__math/error_functions.h
@@ -23,33 +23,37 @@ namespace __math {
 
 // erf
 
-inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT { return __builtin_erff(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT { return __builtin_erff(__x); }
 
 template <class = int>
 _LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT {
   return __builtin_erf(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT { return __builtin_erfl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {
+  return __builtin_erfl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double erf(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double erf(_A1 __x) _NOEXCEPT {
   return __builtin_erf((double)__x);
 }
 
 // erfc
 
-inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT { return __builtin_erfcf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT { return __builtin_erfcf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT {
   return __builtin_erfc(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT { return __builtin_erfcl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {
+  return __builtin_erfcl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double erfc(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double erfc(_A1 __x) _NOEXCEPT {
   return __builtin_erfc((double)__x);
 }
 
diff --git a/libcxx/include/__math/exponential_functions.h b/libcxx/include/__math/exponential_functions.h
index 09930b7819e23..124c367baae4e 100644
--- a/libcxx/include/__math/exponential_functions.h
+++ b/libcxx/include/__math/exponential_functions.h
@@ -26,139 +26,155 @@ namespace __math {
 
 // exp
 
-inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT { return __builtin_expf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT { return __builtin_expf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT {
   return __builtin_exp(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT { return __builtin_expl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {
+  return __builtin_expl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double exp(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double exp(_A1 __x) _NOEXCEPT {
   return __builtin_exp((double)__x);
 }
 
 // frexp
 
-inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT { return __builtin_frexpf(__x, __e); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {
+  return __builtin_frexpf(__x, __e);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT {
   return __builtin_frexp(__x, __e);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {
   return __builtin_frexpl(__x, __e);
 }
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double frexp(_A1 __x, int* __e) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double frexp(_A1 __x, int* __e) _NOEXCEPT {
   return __builtin_frexp((double)__x, __e);
 }
 
 // ldexp
 
-inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT { return __builtin_ldexpf(__x, __e); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {
+  return __builtin_ldexpf(__x, __e);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT {
   return __builtin_ldexp(__x, __e);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {
   return __builtin_ldexpl(__x, __e);
 }
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double ldexp(_A1 __x, int __e) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double ldexp(_A1 __x, int __e) _NOEXCEPT {
   return __builtin_ldexp((double)__x, __e);
 }
 
 // exp2
 
-inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT { return __builtin_exp2f(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT { return __builtin_exp2f(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT {
   return __builtin_exp2(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT { return __builtin_exp2l(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {
+  return __builtin_exp2l(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double exp2(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double exp2(_A1 __x) _NOEXCEPT {
   return __builtin_exp2((double)__x);
 }
 
 // expm1
 
-inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT { return __builtin_expm1f(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT { return __builtin_expm1f(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT {
   return __builtin_expm1(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT { return __builtin_expm1l(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {
+  return __builtin_expm1l(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double expm1(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double expm1(_A1 __x) _NOEXCEPT {
   return __builtin_expm1((double)__x);
 }
 
 // scalbln
 
-inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT { return __builtin_scalblnf(__x, __y); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {
+  return __builtin_scalblnf(__x, __y);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT {
   return __builtin_scalbln(__x, __y);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {
   return __builtin_scalblnl(__x, __y);
 }
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double scalbln(_A1 __x, long __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double scalbln(_A1 __x, long __y) _NOEXCEPT {
   return __builtin_scalbln((double)__x, __y);
 }
 
 // scalbn
 
-inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT { return __builtin_scalbnf(__x, __y); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {
+  return __builtin_scalbnf(__x, __y);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT {
   return __builtin_scalbn(__x, __y);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {
   return __builtin_scalbnl(__x, __y);
 }
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double scalbn(_A1 __x, int __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double scalbn(_A1 __x, int __y) _NOEXCEPT {
   return __builtin_scalbn((double)__x, __y);
 }
 
 // pow
 
-inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT { return __builtin_powf(__x, __y); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {
+  return __builtin_powf(__x, __y);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT {
   return __builtin_pow(__x, __y);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {
   return __builtin_powl(__x, __y);
 }
 
 template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> pow(_A1 __x, _A2 __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> pow(_A1 __x, _A2 __y) _NOEXCEPT {
   using __result_type = __promote_t<_A1, _A2>;
   static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
   return __math::pow((__result_type)__x, (__result_type)__y);
diff --git a/libcxx/include/__math/fdim.h b/libcxx/include/__math/fdim.h
index a1081c7bde3d3..118b439cb2522 100644
--- a/libcxx/include/__math/fdim.h
+++ b/libcxx/include/__math/fdim.h
@@ -23,19 +23,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 namespace __math {
 
-inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT { return __builtin_fdimf(__x, __y); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {
+  return __builtin_fdimf(__x, __y);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT {
   return __builtin_fdim(__x, __y);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {
   return __builtin_fdiml(__x, __y);
 }
 
 template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fdim(_A1 __x, _A2 __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fdim(_A1 __x, _A2 __y) _NOEXCEPT {
   using __result_type = __promote_t<_A1, _A2>;
   static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
   return __math::fdim((__result_type)__x, (__result_type)__y);
diff --git a/libcxx/include/__math/fma.h b/libcxx/include/__math/fma.h
index b972d85b89cb3..4e47e3f8290a4 100644
--- a/libcxx/include/__math/fma.h
+++ b/libcxx/include/__math/fma.h
@@ -23,16 +23,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 namespace __math {
 
-inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT {
   return __builtin_fmaf(__x, __y, __z);
 }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
   return __builtin_fma(__x, __y, __z);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double
+fma(long double __x, long double __y, long double __z) _NOEXCEPT {
   return __builtin_fmal(__x, __y, __z);
 }
 
@@ -40,7 +41,7 @@ template <class _A1,
           class _A2,
           class _A3,
           __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
   using __result_type = __promote_t<_A1, _A2, _A3>;
   static_assert(
       !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value),
diff --git a/libcxx/include/__math/gamma.h b/libcxx/include/__math/gamma.h
index 693e111a84e99..3cd691d2ca110 100644
--- a/libcxx/include/__math/gamma.h
+++ b/libcxx/include/__math/gamma.h
@@ -23,17 +23,19 @@ namespace __math {
 
 // lgamma
 
-inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT { return __builtin_lgammaf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT { return __builtin_lgammaf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT {
   return __builtin_lgamma(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT { return __builtin_lgammal(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {
+  return __builtin_lgammal(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double lgamma(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double lgamma(_A1 __x) _NOEXCEPT {
   return __builtin_lgamma((double)__x);
 }
 
@@ -41,17 +43,19 @@ inline _LIBCPP_HIDE_FROM_ABI double lgamma(_A1 __x) _NOEXCEPT {
 
 // tgamma
 
-inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT { return __builtin_tgammaf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT { return __builtin_tgammaf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT {
   return __builtin_tgamma(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT { return __builtin_tgammal(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {
+  return __builtin_tgammal(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double tgamma(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double tgamma(_A1 __x) _NOEXCEPT {
   return __builtin_tgamma((double)__x);
 }
 
diff --git a/libcxx/include/__math/hyperbolic_functions.h b/libcxx/include/__math/hyperbolic_functions.h
index 78832bae70c9d..e02448e0c5330 100644
--- a/libcxx/include/__math/hyperbolic_functions.h
+++ b/libcxx/include/__math/hyperbolic_functions.h
@@ -23,49 +23,55 @@ namespace __math {
 
 // cosh
 
-inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT { return __builtin_coshf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT { return __builtin_coshf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT {
   return __builtin_cosh(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT { return __builtin_coshl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {
+  return __builtin_coshl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double cosh(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double cosh(_A1 __x) _NOEXCEPT {
   return __builtin_cosh((double)__x);
 }
 
 // sinh
 
-inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT { return __builtin_sinhf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT { return __builtin_sinhf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT {
   return __builtin_sinh(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT { return __builtin_sinhl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {
+  return __builtin_sinhl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double sinh(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double sinh(_A1 __x) _NOEXCEPT {
   return __builtin_sinh((double)__x);
 }
 
 // tanh
 
-inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT { return __builtin_tanhf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT { return __builtin_tanhf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT {
   return __builtin_tanh(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT { return __builtin_tanhl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {
+  return __builtin_tanhl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double tanh(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double tanh(_A1 __x) _NOEXCEPT {
   return __builtin_tanh((double)__x);
 }
 
diff --git a/libcxx/include/__math/hypot.h b/libcxx/include/__math/hypot.h
index 2b12d7be21072..7b87448496bf3 100644
--- a/libcxx/include/__math/hypot.h
+++ b/libcxx/include/__math/hypot.h
@@ -31,19 +31,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 namespace __math {
 
-inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT { return __builtin_hypotf(__x, __y); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {
+  return __builtin_hypotf(__x, __y);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT {
   return __builtin_hypot(__x, __y);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {
   return __builtin_hypotl(__x, __y);
 }
 
 template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> hypot(_A1 __x, _A2 __y) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> hypot(_A1 __x, _A2 __y) _NOEXCEPT {
   using __result_type = __promote_t<_A1, _A2>;
   static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
   return __math::hypot((__result_type)__x, (__result_type)__y);
@@ -79,11 +81,15 @@ _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) {
   return __math::sqrt(__x * __x + __y * __y + __z * __z) / __scale;
 }
 
-inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) { return __math::__hypot(__x, __y, __z); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) {
+  return __math::__hypot(__x, __y, __z);
+}
 
-inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) { return __math::__hypot(__x, __y, __z); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) {
+  return __math::__hypot(__x, __y, __z);
+}
 
-inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) {
   return __math::__hypot(__x, __y, __z);
 }
 
@@ -91,7 +97,7 @@ template <class _A1,
           class _A2,
           class _A3,
           std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 >
-_LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
   using __result_type = __promote_t<_A1, _A2, _A3>;
   static_assert(!(
       std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>));
diff --git a/libcxx/include/__math/inverse_hyperbolic_functions.h b/libcxx/include/__math/inverse_hyperbolic_functions.h
index 4660a58e4eba0..922a5ea6fb7a5 100644
--- a/libcxx/include/__math/inverse_hyperbolic_functions.h
+++ b/libcxx/include/__math/inverse_hyperbolic_functions.h
@@ -23,49 +23,49 @@ namespace __math {
 
 // acosh
 
-inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT { return __builtin_acoshf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT { return __builtin_acoshf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT {
   return __builtin_acosh(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT { return __builtin_acoshl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT { return __builtin_acoshl(__x); }
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double acosh(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double acosh(_A1 __x) _NOEXCEPT {
   return __builtin_acosh((double)__x);
 }
 
 // asinh
 
-inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT { return __builtin_asinhf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT { return __builtin_asinhf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT {
   return __builtin_asinh(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT { return __builtin_asinhl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT { return __builtin_asinhl(__x); }
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double asinh(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double asinh(_A1 __x) _NOEXCEPT {
   return __builtin_asinh((double)__x);
 }
 
 // atanh
 
-inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT { return __builtin_atanhf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT { return __builtin_atanhf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT {
   return __builtin_atanh(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT { return __builtin_atanhl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT { return __builtin_atanhl(__x); }
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double atanh(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double atanh(_A1 __x) _NOEXCEPT {
   return __builtin_atanh((double)__x);
 }
 
diff --git a/libcxx/include/__math/inverse_trigonometric_functions.h b/libcxx/include/__math/inverse_trigonometric_functions.h
index 409500278e7a9..b86204c64a1c9 100644
--- a/libcxx/include/__math/inverse_trigonometric_functions.h
+++ b/libcxx/include/__math/inverse_trigonometric_functions.h
@@ -26,67 +26,75 @@ namespace __math {
 
 // acos
 
-inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT { return __builtin_acosf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT { return __builtin_acosf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT {
   return __builtin_acos(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT { return __builtin_acosl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {
+  return __builtin_acosl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double acos(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double acos(_A1 __x) _NOEXCEPT {
   return __builtin_acos((double)__x);
 }
 
 // asin
 
-inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT { return __builtin_asinf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT { return __builtin_asinf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT {
   return __builtin_asin(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT { return __builtin_asinl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {
+  return __builtin_asinl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double asin(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double asin(_A1 __x) _NOEXCEPT {
   return __builtin_asin((double)__x);
 }
 
 // atan
 
-inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT { return __builtin_atanf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT { return __builtin_atanf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT {
   return __builtin_atan(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT { return __builtin_atanl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {
+  return __builtin_atanl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double atan(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double atan(_A1 __x) _NOEXCEPT {
   return __builtin_atan((double)__x);
 }
 
 // atan2
 
-inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT { return __builtin_atan2f(__y, __x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {
+  return __builtin_atan2f(__y, __x);
+}
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT {
   return __builtin_atan2(__x, __y);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {
   return __builtin_atan2l(__y, __x);
 }
 
 template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> atan2(_A1 __y, _A2 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> atan2(_A1 __y, _A2 __x) _NOEXCEPT {
   using __result_type = __promote_t<_A1, _A2>;
   static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
   return __math::atan2((__result_type)__y, (__result_type)__x);
diff --git a/libcxx/include/__math/trigonometric_functions.h b/libcxx/include/__math/trigonometric_functions.h
index 0ad91c7631609..b312438d4c08a 100644
--- a/libcxx/include/__math/trigonometric_functions.h
+++ b/libcxx/include/__math/trigonometric_functions.h
@@ -23,49 +23,55 @@ namespace __math {
 
 // cos
 
-inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT { return __builtin_cosf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT { return __builtin_cosf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT {
   return __builtin_cos(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT { return __builtin_cosl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {
+  return __builtin_cosl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double cos(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double cos(_A1 __x) _NOEXCEPT {
   return __builtin_cos((double)__x);
 }
 
 // sin
 
-inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT { return __builtin_sinf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT { return __builtin_sinf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT {
   return __builtin_sin(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT { return __builtin_sinl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {
+  return __builtin_sinl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double sin(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double sin(_A1 __x) _NOEXCEPT {
   return __builtin_sin((double)__x);
 }
 
 // tan
 
-inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT { return __builtin_tanf(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT { return __builtin_tanf(__x); }
 
 template <class = int>
-_LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT {
   return __builtin_tan(__x);
 }
 
-inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT { return __builtin_tanl(__x); }
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {
+  return __builtin_tanl(__x);
+}
 
 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
-inline _LIBCPP_HIDE_FROM_ABI double tan(_A1 __x) _NOEXCEPT {
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double tan(_A1 __x) _NOEXCEPT {
   return __builtin_tan((double)__x);
 }
 
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index bee743f702d01..90e348880157c 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -586,21 +586,23 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
     return __x < __b ? __x : __b;
 }
 
-_LIBCPP_HIDE_FROM_ABI inline constexpr float lerp(float __a, float __b, float __t) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline constexpr float lerp(float __a, float __b, float __t) _NOEXCEPT {
   return __lerp(__a, __b, __t);
 }
 
-_LIBCPP_HIDE_FROM_ABI inline constexpr double lerp(double __a, double __b, double __t) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline constexpr double lerp(double __a, double __b, double __t) _NOEXCEPT {
   return __lerp(__a, __b, __t);
 }
 
-_LIBCPP_HIDE_FROM_ABI inline constexpr long double lerp(long double __a, long double __b, long double __t) _NOEXCEPT {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline constexpr long double
+lerp(long double __a, long double __b, long double __t) _NOEXCEPT {
   return __lerp(__a, __b, __t);
 }
 
 template <class _A1, class _A2, class _A3>
   requires(is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>)
-_LIBCPP_HIDE_FROM_ABI inline constexpr __promote_t<_A1, _A2, _A3> lerp(_A1 __a, _A2 __b, _A3 __t) noexcept {
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline constexpr __promote_t<_A1, _A2, _A3>
+lerp(_A1 __a, _A2 __b, _A3 __t) noexcept {
   using __result_type = __promote_t<_A1, _A2, _A3>;
   static_assert(!(
       _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value));
diff --git a/libcxx/test/libcxx/diagnostics/cmath.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/cmath.nodiscard.verify.cpp
index 14d1935bd5030..25ebcfe727025 100644
--- a/libcxx/test/libcxx/diagnostics/cmath.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/cmath.nodiscard.verify.cpp
@@ -17,6 +17,7 @@
 // clang-format off
 
 #include <cmath>
+
 #include "test_macros.h"
 
 void test() {
@@ -110,6 +111,8 @@ void test() {
   std::isunordered(0, 0);        // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::isunordered(0U, 0U);      // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
 
+  // Basic operations
+
   std::ceil(0.f);                // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::ceil(0.l);                // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::ceil(0);                  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
@@ -164,4 +167,185 @@ void test() {
   std::trunc(0.l);               // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::trunc(0);                 // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::trunc(0U);                // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // clang-format on
+
+  // Error functions
+
+  std::erf(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::erf(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::erf(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::erf(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::erfc(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::erfc(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::erfc(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::erfc(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Exponential functions
+
+  std::exp(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::exp(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::exp(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::exp(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Floating point manipulation functions
+
+  std::frexp(0.F, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::frexp(0., 0);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::frexp(0.L, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::frexp(0U, 0);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::ldexp(0.F, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::ldexp(0., 0);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::ldexp(0.L, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::ldexp(0U, 0);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Exponential functions
+
+  std::exp2(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::exp2(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::exp2(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::exp2(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::expm1(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::expm1(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::expm1(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::expm1(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Floating point manipulation functions
+
+  std::scalbln(0.F, 0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::scalbln(0., 0.L);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::scalbln(0.L, 0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::scalbln(0U, 0.L);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::scalbn(0.F, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::scalbn(0., 0);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::scalbn(0.L, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::scalbn(0U, 0);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Power functions
+
+  std::pow(0.F, 0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::pow(0., 0.);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::pow(0.L, 0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::pow(0U, 0U);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Basic operations
+
+  std::fdim(0.F, 0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::fdim(0., 0.);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::fdim(0.L, 0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::fdim(0U, 0U);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::fma(0.F, 0.F, 0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::fma(0., 0., 0.);    // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::fma(0.L, 0.L, 0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::fma(0U, 0U, 0U);    // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Error functions
+
+  std::lgamma(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::lgamma(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::lgamma(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::lgamma(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::tgamma(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::tgamma(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::tgamma(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::tgamma(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Hyperbolic functions
+
+  std::cosh(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::cosh(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::cosh(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::cosh(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::sinh(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::sinh(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::sinh(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::sinh(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::tanh(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::tanh(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::tanh(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::tanh(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Power functions
+
+  std::hypot(0.F, 0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::hypot(0., 0.);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::hypot(0.L, 0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::hypot(0U, 0U);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+#if TEST_STD_VER >= 17
+
+  std::hypot(
+      0.F, 0.F, 0.F);     // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::hypot(0., 0., 0.); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::hypot(
+      0.L, 0.L, 0.L);     // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::hypot(0U, 0U, 0U); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+#endif // _LIBCPP_STD_VER >= 17
+
+  // Hyperbolic functions
+
+  std::acosh(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::acosh(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::acosh(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::acosh(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::asinh(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::asinh(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::asinh(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::asinh(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::atanh(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atanh(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atanh(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atanh(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Trigonometric functions
+
+  std::acos(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::acos(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::acos(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::acos(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::asin(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::asin(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::asin(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::asin(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::atan(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atan(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atan(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atan(0U);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  std::atan2(0.F, 0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atan2(0., 0.);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atan2(0.L, 0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::atan2(0U, 0U);   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // Trigonometric functions
+
+  std::cos(0.F); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::cos(0.);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::cos(0.L); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // [c.math.lerp], linear interpolation
+
+#if TEST_STD_VER >= 20
+  // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::lerp(0.F, 0.F, 0.F);
+  // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::lerp(0., 0., 0.);
+  // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::lerp(0.L, 0.L, 0.L);
+  // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
+  std::lerp(0U, 0U, 0U);
+#endif
 }



More information about the libcxx-commits mailing list