@@ -8476,24 +8476,25 @@ static bool IsInfinityFunction(const FunctionDecl *FDecl) {
84768476
84778477void Sema::CheckInfNaNFunction(const CallExpr *Call,
84788478 const FunctionDecl *FDecl) {
8479+ if (!FDecl->getIdentifier()) {
8480+ return;
8481+ }
8482+
84798483 FPOptions FPO = Call->getFPFeaturesInEffect(getLangOpts());
8480- bool HasIdentifier = FDecl->getIdentifier() != nullptr;
8481- bool IsNaNOrIsUnordered =
8482- IsStdFunction(FDecl, "isnan") || IsStdFunction(FDecl, "isunordered");
8483- bool IsSpecialNaN =
8484- HasIdentifier && IsInfOrNanFunction(FDecl->getName(), MathCheck::NaN);
8485- if ((IsNaNOrIsUnordered || IsSpecialNaN) && FPO.getNoHonorNaNs()) {
8484+ if (FPO.getNoHonorNaNs() &&
8485+ (IsStdFunction(FDecl, "isnan") || IsStdFunction(FDecl, "isunordered") ||
8486+ IsInfOrNanFunction(FDecl->getName(), MathCheck::NaN))) {
84868487 Diag(Call->getBeginLoc(), diag::warn_fp_nan_inf_when_disabled)
84878488 << 1 << 0 << Call->getSourceRange();
8488- } else {
8489- bool IsInfOrIsFinite =
8490- IsStdFunction(FDecl, "isinf") || IsStdFunction(FDecl, "isfinite");
8491- bool IsInfinityOrIsSpecialInf =
8492- HasIdentifier && (IsInfinityFunction( FDecl) ||
8493- IsInfOrNanFunction (FDecl->getName(), MathCheck::Inf));
8494- if ((IsInfOrIsFinite || IsInfinityOrIsSpecialInf) && FPO.getNoHonorInfs())
8495- Diag(Call->getBeginLoc(), diag::warn_fp_nan_inf_when_disabled)
8496- << 0 << 0 << Call->getSourceRange();
8489+ return;
8490+ }
8491+
8492+ if (FPO.getNoHonorInfs() &&
8493+ (IsStdFunction(FDecl, "isinf") || IsStdFunction( FDecl, "isfinite" ) ||
8494+ IsInfinityFunction (FDecl) ||
8495+ IsInfOrNanFunction(FDecl->getName(), MathCheck::Inf))) {
8496+ Diag(Call->getBeginLoc(), diag::warn_fp_nan_inf_when_disabled)
8497+ << 0 << 0 << Call->getSourceRange();
84978498 }
84988499}
84998500
0 commit comments