[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 22 13:13:27 PDT 2025


================
@@ -17945,15 +17945,36 @@ bool Expr::tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx,
 
 static bool EvaluateBuiltinStrLen(const Expr *E, uint64_t &Result,
                                   EvalInfo &Info, std::string *StringResult) {
-  if (!E->getType()->hasPointerRepresentation() || !E->isPRValue())
----------------
apple-fcloutier wrote:

Mh, I don't love checking the same thing twice. I reorganized things a little differently to avoid the `else { return false }` branch.

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


More information about the cfe-commits mailing list