[clang] [Clang][ExprConstant] fix constant expression did not evaluate to integer (PR #97146)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 29 00:51:47 PDT 2024


================
@@ -15858,7 +15858,7 @@ static bool FastEvaluateAsRValue(const Expr *Exp, Expr::EvalResult &Result,
   }
 
   if (const auto *CE = dyn_cast<ConstantExpr>(Exp)) {
-    if (CE->hasAPValueResult()) {
+    if (CE->hasAPValueResult() && !CE->getAPValueResult().isLValue()) {
----------------
tbaederr wrote:

It looks like `ConstantExpr::getAPValueResult()` will sometimes create a new APValue, so we should try ti call `getAPValueResult()` only once.

https://github.com/llvm/llvm-project/pull/97146


More information about the cfe-commits mailing list