[libc-commits] [PATCH] D157449: [libc] Fix final conversion warnings
Michael Jones via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Aug 8 15:28:15 PDT 2023
michaelrj created this revision.
michaelrj added reviewers: mcgrathr, lntue, sivachandra, abrachet, Caslyn.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
michaelrj requested review of this revision.
This patch fixes the floating point conversion warnings found with
`-Wconversion` and `-Wno-sign-conversion`. These were the last warnings
I found, meaning that once this lands https://reviews.llvm.org/D156630
should be unblocked.
Repository:
rG LLVM Github Monorepo
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
@@ -62,9 +62,9 @@
int idx = static_cast<int>(sign);
if (LIBC_UNLIKELY(xbits.is_inf()))
- return SIGNS[idx][0];
+ return static_cast<float>(SIGNS[idx][0]);
- return SIGNS[idx][0] + SIGNS[idx][1];
+ return static_cast<float>(SIGNS[idx][0] + SIGNS[idx][1]);
}
// Range reduction: e^(2x) = 2^(hi + mid) * e^lo
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.548379.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230808/11e35e76/attachment.bin>
More information about the libc-commits
mailing list