[libc-commits] [PATCH] D157449: [libc] Fix final conversion warnings

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 9 10:24:20 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe328d193024e: [libc] Fix final conversion warnings (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157449/new/

https://reviews.llvm.org/D157449

Files:
  libc/src/math/generic/exp2f.cpp
  libc/src/math/generic/tanhf.cpp
  libc/src/time/difftime.cpp


Index: libc/src/time/difftime.cpp
===================================================================
--- libc/src/time/difftime.cpp
+++ libc/src/time/difftime.cpp
@@ -12,7 +12,7 @@
 namespace __llvm_libc {
 
 LLVM_LIBC_FUNCTION(double, difftime, (time_t end, time_t beginning)) {
-  return end - beginning;
+  return static_cast<double>(end - beginning);
 }
 
 } // namespace __llvm_libc
Index: libc/src/math/generic/tanhf.cpp
===================================================================
--- libc/src/math/generic/tanhf.cpp
+++ libc/src/math/generic/tanhf.cpp
@@ -56,7 +56,7 @@
     if (LIBC_UNLIKELY(xbits.is_nan()))
       return x + 1.0f; // sNaN to qNaN + signal
 
-    const double SIGNS[2][2] = {{1.0f, -0x1.0p-25f}, {-1.0f, 0x1.0p-25f}};
+    constexpr float SIGNS[2][2] = {{1.0f, -0x1.0p-25f}, {-1.0f, 0x1.0p-25f}};
 
     bool sign = xbits.get_sign();
     int idx = static_cast<int>(sign);
Index: libc/src/math/generic/exp2f.cpp
===================================================================
--- libc/src/math/generic/exp2f.cpp
+++ libc/src/math/generic/exp2f.cpp
@@ -65,7 +65,7 @@
       double c2 = fputil::multiply_add(xd, COEFFS[5], COEFFS[4]);
       double p = fputil::polyeval(xsq, c0, c1, c2);
       double r = fputil::multiply_add(p, xd, 1.0);
-      return r;
+      return static_cast<float>(r);
     }
 
     // x >= 128


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157449.548670.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230809/d7656aa9/attachment.bin>


More information about the libc-commits mailing list