[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 10 06:10:08 PST 2024
================
@@ -9090,10 +9092,16 @@ bool Sema::SemaBuiltinVAStartARMMicrosoft(CallExpr *Call) {
/// SemaBuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
/// friends. This is declared to take (...), so we have to check everything.
-bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
+bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID) {
if (checkArgCount(*this, TheCall, 2))
return true;
+ if (BuiltinID == Builtin::BI__builtin_isunordered) {
+ if (TheCall->getFPFeaturesInEffect(getLangOpts()).getNoHonorNaNs())
+ Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
+ << "NaN" << TheCall->getSourceRange();
+ }
----------------
AaronBallman wrote:
```suggestion
if (BuiltinID == Builtin::BI__builtin_isunordered &&
TheCall->getFPFeaturesInEffect(getLangOpts()).getNoHonorNaNs())
Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
<< "NaN" << TheCall->getSourceRange();
```
https://github.com/llvm/llvm-project/pull/76873
More information about the cfe-commits
mailing list