[clang] [clang][bytecode] Add opaque pointers to support type-only pointers (PR #213017)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 5 02:06:33 PDT 2026
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/213017 at github.com>
================
@@ -2524,14 +2315,28 @@ static bool interp__builtin_object_size(InterpState &S, CodePtr OpPC,
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());
+ pushInteger(S, Kind <= 1 ? (size_t)-1 : (size_t)0, Call->getType());
return true;
}
- if (auto Result = evaluateBuiltinObjectSize(ASTCtx, Kind, Ptr)) {
+ if (auto Result = evaluateBuiltinObjectSize(ASTCtx, Kind, Ptr,
+ Call->getArg(0), IsDynamic)) {
pushInteger(S, *Result, Call->getType());
return true;
}
+
+ switch (S.EvalMode) {
+ case EvaluationMode::ConstantExpression:
+ case EvaluationMode::ConstantFold:
+ case EvaluationMode::IgnoreSideEffects:
+ // Leave it to IR generation.
+ return Invalid(S, OpPC);
+ case EvaluationMode::ConstantExpressionUnevaluated:
+ // Reduce it to a constant now.
+ pushInteger(S, ((Kind & 2u) ? (size_t)0 : (size_t)-1), Call->getType());
----------------
tbaederr wrote:
Not sure what that is, this is just what the Kind/Type parameter to `__builtin_object_size` is.
https://github.com/llvm/llvm-project/pull/213017
More information about the cfe-commits
mailing list