[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 12 10:08:46 PDT 2025
================
@@ -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);
----------------
cor3ntin wrote:
Sorry about that, I meant `EvaluateStringLiteralSize` - ie split the method in 2. Pseudo code
```cpp
if(StringLiteral* SL = GetLValueAsStringLiteral(LValue))
Size = EvaluateStringLiteralSize(SL, Offset);
```
I believe the second method never fails but I might be wrong about that, use optional if it can.
Does that make some sense?
https://github.com/llvm/llvm-project/pull/135864
More information about the cfe-commits
mailing list