[PATCH] D147906: [clang-tidy] Avoid float compare in bugprone-incorrect-roundings

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 05:12:52 PDT 2023


PiotrZSL marked an inline comment as done.
PiotrZSL added a comment.

D147908 <https://reviews.llvm.org/D147908> fixes comments from this on, it's just split into 2 reviews, this as fixing issue, and other as introducing improvment.



================
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:
> 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());
> ```
This get re-worked in D147908, that depend on this change.


================
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;
----------------
PiotrZSL wrote:
> carlosgalvezp wrote:
> > 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());
> > ```
> This get re-worked in D147908, that depend on this change.
This get reworked in D147908.


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