Skip to content

Commit

Permalink
[libc] Fix final conversion warnings
Browse files Browse the repository at this point in the history
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.

Reviewed By: mcgrathr, lntue

Differential Revision: https://reviews.llvm.org/D157449
  • Loading branch information
michaelrj-google committed Aug 9, 2023
1 parent dcd3a0c commit e328d19
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libc/src/math/generic/exp2f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ LLVM_LIBC_FUNCTION(float, exp2f, (float x)) {
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
Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/tanhf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ LLVM_LIBC_FUNCTION(float, tanhf, (float x)) {
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);
Expand Down
2 changes: 1 addition & 1 deletion libc/src/time/difftime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e328d19

Please sign in to comment.