================
@@ -8454,26 +8454,43 @@ static bool IsInfOrNanFunction(StringRef calleeName,
MathCheck Check) {
llvm_unreachable("unknown MathCheck");
}
+static bool IsInfinityFunction(const FunctionDecl *FDecl) {
+ if (FDecl->getName() != "infinity")
+ return false;
+
+ if (const CXXMethodDecl *MDecl = dyn_cast<CXXMethodDecl>(FDecl)) {
+ const CXXRecordDecl *RDecl = MDecl->getParent();
+ if (RDecl->getName() != "numeric_limits")
+ return false;
+
+ if (const NamespaceDecl *NSDecl =
+ dyn_cast<NamespaceDecl>(RDecl->getDeclContext()))
+ return NSDecl->isStdNamespace();
+ }
+
+ return false;
+}
+
void Sema::CheckInfNaNFunction(const CallExpr *Call,
const FunctionDecl *FDecl) {
+ if (!FDecl->getIdentifier())
----------------
AmrDeveloper wrote:
The problem with this is in case of `FPO.getNoHonorNaNs() == false` we
performed un needed 3 function call, and in case of it's true we performed 3
more un needed too `IsInfOrIsFinite`, `IsInfinityOrIsSpecialInf`
```call
bool IsNaNOrIsUnordered =
IsStdFunction(FDecl, "isnan") || IsStdFunction(FDecl, "isunordered");
bool IsSpecialNaN =
IsInfOrNanFunction(FDecl->getName(), MathCheck::NaN);
if ((IsNaNOrIsUnordered || IsSpecialNaN) && false) { <--- Condition will
evaluated to false
}
```
https://github.com/llvm/llvm-project/pull/123417
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits