[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 12 03:31:14 PDT 2025
=?utf-8?q?F=C3=A9lix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?F=C3=A9lix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?F=C3=A9lix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?F=C3=A9lix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?F=C3=A9lix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?F=C3=A9lix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?F=C3=A9lix?= Cloutier <fcloutier at apple.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/135864 at github.com>
================
@@ -791,10 +791,26 @@ class Expr : public ValueStmt {
const Expr *PtrExpression, ASTContext &Ctx,
EvalResult &Status) const;
- /// If the current Expr can be evaluated to a pointer to a null-terminated
- /// constant string, return the constant string (without the terminating
- /// null).
- std::optional<std::string> tryEvaluateString(ASTContext &Ctx) const;
+ class StringEvalResult {
+ std::string Storage;
+ const StringLiteral *SL;
+ uint64_t Offset;
+
+ public:
+ StringEvalResult(std::string Contents);
+ StringEvalResult(const StringLiteral *SL, uint64_t Offset);
+
+ llvm::StringRef getString() const;
+ bool getStringLiteral(const StringLiteral *&SL, uint64_t &Offset) const;
+ };
----------------
cor3ntin wrote:
Could that just an aggregate, that we could use with structured binding?
https://github.com/llvm/llvm-project/pull/135864
More information about the cfe-commits
mailing list