This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Avoid float compare in bugprone-incorrect-roundings
ClosedPublic

Authored by PiotrZSL on Apr 9 2023, 11:07 PM.

Details

Summary

Using APFloat to compare floating numbers instead of float/double.

Fixes: 46424

Diff Detail

Event Timeline

PiotrZSL created this revision.Apr 9 2023, 11:07 PM
Herald added a project: Restricted Project. · View Herald Transcript
PiotrZSL requested review of this revision.Apr 9 2023, 11:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2023, 11:07 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Looks good, small suggestions! I appreciate having this small patch prior to the next one fixing the actual issue.

clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp
31

Remove static

31

I think you can just combine those lines into one to get rid of the variable.

return Literal == getHalf(llvm::APFloat::IEEEsingle());
PiotrZSL marked an inline comment as done.Apr 10 2023, 5:12 AM

D147908 fixes comments from this on, it's just split into 2 reviews, this as fixing issue, and other as introducing improvment.

clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp
31

This get re-worked in D147908, that depend on this change.

31

This get reworked in D147908.

PiotrZSL marked an inline comment as done.Apr 10 2023, 5:16 AM
PiotrZSL marked an inline comment as done.
PiotrZSL updated this revision to Diff 512149.Apr 10 2023, 8:07 AM

Fix review comments

carlosgalvezp accepted this revision.Apr 15 2023, 1:09 AM
This revision is now accepted and ready to land.Apr 15 2023, 1:09 AM