[clang] [clang][bytecode] Use in `Expr::tryEvaluateObjectSize` (PR #179033)
marius doerner via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 31 09:34:31 PST 2026
Marius =?utf-8?q?Dörner?= <marius.doerner1 at icloud.com>,marius doerner
<marius.doerner1 at icloud.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/179033 at github.com>
================
@@ -327,6 +327,35 @@ bool Context::evaluateStrlen(State &Parent, const Expr *E, uint64_t &Result) {
return true;
}
+bool Context::tryEvaluateObjectSize(State &Parent, const Expr *E, unsigned Kind,
+ uint64_t &Result) {
+ assert(Stk.empty());
+ Compiler<EvalEmitter> C(*this, *P, Parent, Stk);
+
+ auto PtrRes = C.interpretAsPointer(E, [&](const Pointer &Ptr) {
+ const Descriptor *DeclDesc = Ptr.getDeclDesc();
+ assert(DeclDesc);
+ QualType T = DeclDesc->getType().getNonReferenceType();
+ if (T->isIncompleteType() || T->isFunctionType() ||
+ !T->isConstantSizeType())
+ return false;
+
+ Pointer P = Ptr;
----------------
mariusdr wrote:
The pointer may be mutated in evaluateBuiltinObjectSize.
https://github.com/mariusdr/llvm-project/blob/0aa75255d81861952aa572d51612e5e65b906822/clang/lib/AST/ByteCode/InterpBuiltin.cpp#L2337-L2341
https://github.com/llvm/llvm-project/pull/179033
More information about the cfe-commits
mailing list