[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 12 11:08:08 PDT 2025
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/135864 at github.com>
================
@@ -1920,9 +1920,17 @@ static bool EvaluateComplex(const Expr *E, ComplexValue &Res, EvalInfo &Info);
static bool EvaluateAtomic(const Expr *E, const LValue *This, APValue &Result,
EvalInfo &Info);
static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result);
+static bool EvaluateStringAsLValue(EvalInfo &Info, const Expr *E,
+ QualType &CharTy, LValue &String);
+static const StringLiteral *StringLValueIsLiteral(EvalInfo &Info,
+ LValue &String,
+ QualType CharTy,
+ uint64_t &Offset);
----------------
apple-fcloutier wrote:
The explanation makes sense now, thank you. From what I can tell, though, `GetLValueAsStringLiteral` would just be `dyn_cast_or_null<StringLiteral>(String.getLValueBase().dyn_cast<const Expr *>())`, and `EvaluateStringLiteralSize` would be the rest of the current `StringLValueIsLiteral`. It would also need to take all of the current `EvalInfo`, `LValue` and `QualType` arguments instead of the `StringLiteral` value. I think this makes the separation rather awkward. I'm still planning to rename it to `GetLValueAsStringLiteralAndOffset` or something like that.
https://github.com/llvm/llvm-project/pull/135864
More information about the cfe-commits
mailing list