[PATCH] D147906: [clang-tidy] Avoid float compare in bugprone-incorrect-roundings
Carlos Galvez via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 10 04:34:25 PDT 2023
carlosgalvezp added a comment.
Looks good, small suggestions! I appreciate having this small patch prior to the next one fixing the actual issue.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp:28
+ if ((&Node.getSemantics()) == &llvm::APFloat::IEEEsingle()) {
+ static llvm::APFloat Half = getHalf(llvm::APFloat::IEEEsingle());
+ return Literal == Half;
----------------
Remove `static`
================
Comment at: clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp:28
+ if ((&Node.getSemantics()) == &llvm::APFloat::IEEEsingle()) {
+ static llvm::APFloat Half = getHalf(llvm::APFloat::IEEEsingle());
+ return Literal == Half;
----------------
carlosgalvezp wrote:
> Remove `static`
I think you can just combine those lines into one to get rid of the variable.
```
return Literal == getHalf(llvm::APFloat::IEEEsingle());
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147906/new/
https://reviews.llvm.org/D147906
More information about the cfe-commits
mailing list