[clang] [Clang] Add constexpr eval for cmath builtins (PR #194327)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 8 09:22:25 PDT 2026
================
@@ -199,6 +199,25 @@ static llvm::APSInt convertBoolVectorToInt(const Pointer &Val) {
return Result;
}
+static bool CheckFloatResult(InterpState &S, CodePtr OpPC,
+ const APFloat &Result, APFloat::opStatus Status) {
+ if (S.inConstantContext())
+ return true;
+
+ // If any of the following exceptions were raised, the operation is not a
+ // constant expression.
+ if (Status & (APFloat::opInvalidOp | APFloat::opOverflow |
+ APFloat::opUnderflow | APFloat::opDivByZero)) {
+ if (!S.checkingPotentialConstantExpression()) {
+ const SourceInfo &Loc = S.Current->getSource(OpPC);
+ S.CCEDiag(Loc, diag::note_constexpr_float_arithmetic) << Result.isNaN();
----------------
Serosh-commits wrote:
> Minor nit: CheckFloatResult could provide more specific diagnostics about which FP exception occurred. This can be deferred to a follow-up PR.
yeah sure i will add up a follow up pr for this thanks
https://github.com/llvm/llvm-project/pull/194327
More information about the cfe-commits
mailing list