[libc-commits] [libc] [libc][math] Qualify all math functions to be constexpr (PR #195623)

via libc-commits libc-commits at lists.llvm.org
Mon May 4 02:39:59 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 h,cpp -- libc/src/__support/FPUtil/FMA.h libc/src/__support/FPUtil/Hypot.h libc/src/__support/FPUtil/ManipulationFunctions.h libc/src/__support/FPUtil/generic/FMA.h libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h libc/src/__support/FPUtil/nearest_integer.h libc/src/__support/math/asin.h libc/src/__support/math/asinpi.h libc/src/__support/math/asinpif16.h libc/src/__support/math/atan2f16.h libc/src/__support/math/atanbf16.h libc/src/__support/math/atanf_float.h libc/src/__support/math/atanpif16.h libc/src/__support/math/bf16add.h libc/src/__support/math/bf16addf.h libc/src/__support/math/bf16addf128.h libc/src/__support/math/bf16addl.h libc/src/__support/math/bf16div.h libc/src/__support/math/bf16divf.h libc/src/__support/math/bf16divf128.h libc/src/__support/math/bf16divl.h libc/src/__support/math/bf16fma.h libc/src/__support/math/bf16fmaf.h libc/src/__support/math/bf16fmaf128.h libc/src/__support/math/bf16fmal.h libc/src/__support/math/bf16mul.h libc/src/__support/math/bf16mulf.h libc/src/__support/math/bf16mulf128.h libc/src/__support/math/bf16mull.h libc/src/__support/math/bf16sub.h libc/src/__support/math/bf16subf.h libc/src/__support/math/bf16subf128.h libc/src/__support/math/canonicalize.h libc/src/__support/math/canonicalizebf16.h libc/src/__support/math/canonicalizef.h libc/src/__support/math/canonicalizef128.h libc/src/__support/math/canonicalizef16.h libc/src/__support/math/canonicalizel.h libc/src/__support/math/cbrtbf16.h libc/src/__support/math/ceill.h libc/src/__support/math/cos_integer_eval.h libc/src/__support/math/daddf128.h libc/src/__support/math/daddl.h libc/src/__support/math/dfmaf128.h libc/src/__support/math/dfmal.h libc/src/__support/math/dsubf128.h libc/src/__support/math/dsubl.h libc/src/__support/math/erfcf16.h libc/src/__support/math/erff16.h libc/src/__support/math/exp.h libc/src/__support/math/exp10f16_utils.h libc/src/__support/math/expf16_utils.h libc/src/__support/math/expxf16_utils.h libc/src/__support/math/f16div.h libc/src/__support/math/f16divf.h libc/src/__support/math/f16divf128.h libc/src/__support/math/f16divl.h libc/src/__support/math/f16fma.h libc/src/__support/math/f16fmaf.h libc/src/__support/math/f16fmaf128.h libc/src/__support/math/f16fmal.h libc/src/__support/math/f16mul.h libc/src/__support/math/f16mulf.h libc/src/__support/math/f16mulf128.h libc/src/__support/math/f16mull.h libc/src/__support/math/f16sqrtf128.h libc/src/__support/math/f16sub.h libc/src/__support/math/f16subf.h libc/src/__support/math/f16subf128.h libc/src/__support/math/f16subl.h libc/src/__support/math/ffma.h libc/src/__support/math/ffmaf128.h libc/src/__support/math/ffmal.h libc/src/__support/math/fma.h libc/src/__support/math/fmabf16.h libc/src/__support/math/fmaf.h libc/src/__support/math/fmaf16.h libc/src/__support/math/fmaxf.h libc/src/__support/math/hypot.h libc/src/__support/math/hypotbf16.h libc/src/__support/math/hypotf.h libc/src/__support/math/hypotf16.h libc/src/__support/math/log10f16.h libc/src/__support/math/log10p1f16.h libc/src/__support/math/log1pf.h libc/src/__support/math/log2f16.h libc/src/__support/math/log2p1f16.h libc/src/__support/math/logf16.h libc/src/__support/math/nextafter.h libc/src/__support/math/nextafterbf16.h libc/src/__support/math/nextafterf.h libc/src/__support/math/nextafterf128.h libc/src/__support/math/nextafterf16.h libc/src/__support/math/nexttoward.h libc/src/__support/math/nexttowardbf16.h libc/src/__support/math/nexttowardf.h libc/src/__support/math/nexttowardf16.h libc/src/__support/math/nexttowardl.h libc/src/__support/math/range_reduction.h libc/src/__support/math/range_reduction_double_common.h libc/src/__support/math/range_reduction_double_fma.h libc/src/__support/math/range_reduction_double_nofma.h libc/src/__support/math/range_reduction_fma.h libc/src/__support/math/setpayloadsig.h libc/src/__support/math/setpayloadsigbf16.h libc/src/__support/math/setpayloadsigf.h libc/src/__support/math/setpayloadsigf128.h libc/src/__support/math/setpayloadsigf16.h libc/src/__support/math/setpayloadsigl.h libc/src/__support/math/sin_integer_eval.h libc/src/__support/math/sincos.h libc/src/__support/math/sincos_integer_utils.h libc/src/__support/math/sincosf_utils.h libc/src/__support/math/sinf.h libc/src/__support/math/sinf16.h libc/src/__support/math/sinhfcoshf_utils.h libc/src/__support/math/sinpif.h libc/src/__support/math/sinpif16.h libc/src/__support/math/sqrt.h libc/src/__support/math/sqrtbf16.h libc/src/__support/math/sqrtf.h libc/src/__support/math/tanf16.h libc/src/__support/math/tanhf16.h libc/src/__support/math/tanpif16.h libc/test/shared/shared_math_constexpr_test.cpp libc/test/shared/shared_math_test.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/libc/src/__support/math/bf16fmal.h b/libc/src/__support/math/bf16fmal.h
index 271fe6dcd..da559936c 100644
--- a/libc/src/__support/math/bf16fmal.h
+++ b/libc/src/__support/math/bf16fmal.h
@@ -16,7 +16,8 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE LIBC_CONSTEXPR bfloat16 bf16fmal(long double x, long double y, long double z) {
+LIBC_INLINE LIBC_CONSTEXPR bfloat16 bf16fmal(long double x, long double y,
+                                             long double z) {
   return fputil::fma<bfloat16>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/dfmal.h b/libc/src/__support/math/dfmal.h
index 349196e8f..2fa79bb6f 100644
--- a/libc/src/__support/math/dfmal.h
+++ b/libc/src/__support/math/dfmal.h
@@ -16,7 +16,8 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE LIBC_CONSTEXPR double dfmal(long double x, long double y, long double z) {
+LIBC_INLINE LIBC_CONSTEXPR double dfmal(long double x, long double y,
+                                        long double z) {
   return fputil::fma<double>(x, y, z);
 }
 
diff --git a/libc/src/__support/math/sqrtbf16.h b/libc/src/__support/math/sqrtbf16.h
index cd401de9e..b0013bf2a 100644
--- a/libc/src/__support/math/sqrtbf16.h
+++ b/libc/src/__support/math/sqrtbf16.h
@@ -17,7 +17,9 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE constexpr bfloat16 sqrtbf16(bfloat16 x) { return fputil::sqrt<bfloat16>(x); }
+LIBC_INLINE constexpr bfloat16 sqrtbf16(bfloat16 x) {
+  return fputil::sqrt<bfloat16>(x);
+}
 
 } // namespace math
 } // namespace LIBC_NAMESPACE_DECL

``````````

</details>


https://github.com/llvm/llvm-project/pull/195623


More information about the libc-commits mailing list