diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 69276ce418fa6..f9fc0ff536254 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -5666,11 +5666,12 @@ bool Sema::BuiltinConstantArg(CallExpr *TheCall, int ArgNum, if (Arg->isTypeDependent() || Arg->isValueDependent()) return false; - std::optional R; - if (!(R = Arg->getIntegerConstantExpr(Context))) + Expr::EvalResult evalRes; + if (!Arg->EvaluateAsInt(evalRes, Context)) { return Diag(TheCall->getBeginLoc(), diag::err_constant_integer_arg_type) << FDecl->getDeclName() << Arg->getSourceRange(); - Result = *R; + } + Result = evalRes.Val.getInt(); return false; }