[clang] [clang][bytecode] Use in `Expr::tryEvaluateObjectSize` (PR #179033)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 31 07:09:50 PST 2026
================
@@ -2301,54 +2301,36 @@ static bool isUserWritingOffTheEnd(const ASTContext &Ctx, const Pointer &Ptr) {
isFlexibleArrayMember(FieldDesc);
}
-static bool interp__builtin_object_size(InterpState &S, CodePtr OpPC,
- const InterpFrame *Frame,
- const CallExpr *Call) {
- const ASTContext &ASTCtx = S.getASTContext();
- // From the GCC docs:
- // Kind is an integer constant from 0 to 3. If the least significant bit is
- // clear, objects are whole variables. If it is set, a closest surrounding
- // subobject is considered the object a pointer points to. The second bit
- // determines if maximum or minimum of remaining bytes is computed.
- unsigned Kind = popToUInt64(S, Call->getArg(1));
- assert(Kind <= 3 && "unexpected kind");
- bool UseFieldDesc = (Kind & 1u);
- bool ReportMinimum = (Kind & 2u);
- Pointer Ptr = S.Stk.pop<Pointer>();
-
- if (Call->getArg(0)->HasSideEffects(ASTCtx)) {
- // "If there are any side effects in them, it returns (size_t) -1
- // for type 0 or 1 and (size_t) 0 for type 2 or 3."
- pushInteger(S, Kind <= 1 ? -1 : 0, Call->getType());
- return true;
- }
-
+UnsignedOrNone EvaluateBuiltinObjectSize(const ASTContext &ASTCtx,
----------------
tbaederr wrote:
```suggestion
UnsignedOrNone evaluateBuiltinObjectSize(const ASTContext &ASTCtx,
```
https://github.com/llvm/llvm-project/pull/179033
More information about the cfe-commits
mailing list