[clang] [clang][bytecode][NFC] Bail out on non constant evaluated builtins (PR #130431)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 8 11:11:44 PST 2025
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/130431
If the ASTContext says so, don't bother trying to constant evaluate the given builtin.
>From 1a085cf37983ca5acef83939371a5fee9d5f1813 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sat, 8 Mar 2025 20:09:41 +0100
Subject: [PATCH] [clang][bytecode][NFC] Bail out on non constant evaluated
builtins
If the ASTContext says so, don't bother trying to constant evaluate the
given builtin.
---
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index b8c4ef2f48a79..14e716daa3f12 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2059,6 +2059,9 @@ static bool interp__builtin_memchr(InterpState &S, CodePtr OpPC,
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
const CallExpr *Call, uint32_t BuiltinID) {
+ if (!S.getASTContext().BuiltinInfo.isConstantEvaluated(BuiltinID))
+ return false;
+
const InterpFrame *Frame = S.Current;
std::optional<PrimType> ReturnT = S.getContext().classify(Call);
More information about the cfe-commits
mailing list