[clang] [clang][ExprConst] Add missing `FastEvaluateAsRValue` in `EvaluateKnownConstIntCheckOverflow` (PR #234552)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 22 02:33:06 PDT 2026


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/234552

This was missing for some reason.

>From 43e42d37ca6a48f66b19c0bd171246657daae949 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 22 Oct 2026 10:48:04 +0200
Subject: [PATCH] asdf

---
 clang/lib/AST/ExprConstant.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d6093b9376afbd..0c5e863bbd475a 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -22707,6 +22707,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);
     Settings.InConstantContext = true;



More information about the cfe-commits mailing list