[clang] c467c6b - [clang][ExprConst] Add missing `FastEvaluateAsRValue` in `EvaluateKnownConstInt{,CheckOverflow}` (#234552)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 24 00:30:33 PDT 2026
Author: Timm Baeder
Date: 2026-10-24T09:30:28+02:00
New Revision: c467c6b1e53dc0939ab78a644eceea6e61cf4953
URL: https://github.com/llvm/llvm-project/commit/c467c6b1e53dc0939ab78a644eceea6e61cf4953
DIFF: https://github.com/llvm/llvm-project/commit/c467c6b1e53dc0939ab78a644eceea6e61cf4953.diff
LOG: [clang][ExprConst] Add missing `FastEvaluateAsRValue` in `EvaluateKnownConstInt{,CheckOverflow}` (#234552)
This was missing for some reason.
Added:
Modified:
clang/lib/AST/ExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index b37aa4de5f2b1..3762bc83c779b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -22802,6 +22802,13 @@ APSInt Expr::EvaluateKnownConstInt(const ASTContext &Ctx) const {
ExprTimeTraceScope TimeScope(this, Ctx, "EvaluateKnownConstInt");
EvalResult EVResult;
+ bool IsConst;
+ if (FastEvaluateAsRValue(this, EVResult.Val, Ctx, IsConst)) {
+ assert(IsConst);
+ assert(EVResult.Val.isInt() && "Expression did not evaluate to integer");
+ return EVResult.Val.getInt();
+ }
+
if (Ctx.getLangOpts().EnableNewConstInterp) {
interp::EvalSettings Settings(EvaluationMode::IgnoreSideEffects, EVResult,
/*SProxy=*/nullptr);
@@ -22835,6 +22842,13 @@ APSInt Expr::EvaluateKnownConstIntCheckOverflow(
EvalResult EVResult;
EVResult.Diag = Diag;
+ bool IsConst;
+ if (FastEvaluateAsRValue(this, EVResult.Val, Ctx, IsConst)) {
+ assert(IsConst);
+ assert(EVResult.Val.isInt() && "Expression did not evaluate to integer");
+ return EVResult.Val.getInt();
+ }
+
if (Ctx.getLangOpts().EnableNewConstInterp) {
interp::EvalSettings Settings(EvaluationMode::IgnoreSideEffects, EVResult,
/*SProxy=*/nullptr);
More information about the cfe-commits
mailing list