[llvm] [clang-tools-extra] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-29 Thread via cfe-commits
mikaelholmen wrote: > > > Is this expected and wanted? > > > > > > Good catch! I would not expect that diagnostic; we should silence the > > diagnostic if it's used in a `#ifdef`, `#elifdef`, or `defined` because the > > value isn't necessary. Perhaps we should also silence something like >

[llvm] [clang-tools-extra] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-24 Thread Zahira Ammarguellat via cfe-commits
zahiraam wrote: > > Is this expected and wanted? > > Good catch! I would not expect that diagnostic; we should silence the > diagnostic if it's used in a `#ifdef`, `#elifdef`, or `defined` because the > value isn't necessary. Perhaps we should also silence something like > `sizeof(INFINITY)`

[llvm] [clang-tools-extra] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-19 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,181 @@ +// Use of NAN macro will trigger a warning "infinity defined in macro" because +// on Windows the NAN macro is defined using INFINITY. See below. + +// RUN: %clang_cc1 -x c++ -verify=no-inf-no-nan -triple powerpc64le-unknown-unknown %s \ +// RUN:

[llvm] [clang-tools-extra] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-19 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. The changes LGTM aside from some minor improvements to the tests. https://github.com/llvm/llvm-project/pull/76873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[llvm] [clang-tools-extra] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-18 Thread Aaron Ballman via cfe-commits
@@ -2835,6 +2835,9 @@ class Preprocessor { if (Identifier.getIdentifierInfo()->isRestrictExpansion() && !SourceMgr.isInMainFile(Identifier.getLocation())) emitRestrictExpansionWarning(Identifier); + +if (Identifier.getIdentifierInfo()->getName() ==

[llvm] [clang-tools-extra] [clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-15 Thread Zahira Ammarguellat via cfe-commits
@@ -13861,6 +13897,36 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, CheckPPCMMAType(RetValExp->getType(), ReturnLoc); } +/// Diagnose comparison to NAN or INFINITY in fast math modes. +/// The comparison to NaN or INFINITY is always false in +/// fast