[clang] [clang] Return std::optional from all Expr::tryEvaluate* API (PR #179230)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 8 12:12:53 PST 2026
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/179230 at github.com>
================
@@ -21659,18 +21659,25 @@ bool Expr::isPotentialConstantExprUnevaluated(Expr *E,
return Diags.empty();
}
-bool Expr::tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx,
- unsigned Type) const {
+std::optional<uint64_t> Expr::tryEvaluateObjectSize(const ASTContext &Ctx,
+ unsigned Type) const {
if (!getType()->isPointerType())
return false;
Expr::EvalStatus Status;
EvalInfo Info(Ctx, Status, EvaluationMode::ConstantFold);
- if (Info.EnableNewConstInterp) {
- return Info.Ctx.getInterpContext().tryEvaluateObjectSize(Info, this, Type,
- Result);
- }
- return tryEvaluateBuiltinObjectSize(this, Type, Info, Result);
+ uint64_t Result = ~0u;
----------------
Sirraide wrote:
Maybe `assert` that `Result` is not equal to `~0u` before we return in that case (or use an optional). Actually, could `tryEvaluateObjectSize`/`tryEvaluateBuiltinObjectSize` just return an optional as well instead of the separate bool return + out parameter?
https://github.com/llvm/llvm-project/pull/179230
More information about the cfe-commits
mailing list