diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5a33e918db8e8c..e5539dedec02a4 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -15327,6 +15327,17 @@ static bool FastEvaluateAsRValue(const Expr *Exp, Expr::EvalResult &Result, return true; } + if (const auto *CE = dyn_cast(Exp)) { + if (CE->hasAPValueResult()) { + Result.Val = CE->getAPValueResult(); + IsConst = true; + return true; + } + + // The SubExpr is usually just an IntegerLiteral. + return FastEvaluateAsRValue(CE->getSubExpr(), Result, Ctx, IsConst); + } + // This case should be rare, but we need to check it before we check on // the type below. if (Exp->getType().isNull()) {