[clang] ab56c9b - [clang][bytecode] Check isActive() in EvalEmitter::speculate() (#174183)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 2 00:48:46 PST 2026
Author: Timm Baeder
Date: 2026-01-02T09:48:41+01:00
New Revision: ab56c9bfbc6832f66abe13417b5804c5f1b1a02d
URL: https://github.com/llvm/llvm-project/commit/ab56c9bfbc6832f66abe13417b5804c5f1b1a02d
DIFF: https://github.com/llvm/llvm-project/commit/ab56c9bfbc6832f66abe13417b5804c5f1b1a02d.diff
LOG: [clang][bytecode] Check isActive() in EvalEmitter::speculate() (#174183)
If this opcode is being jumped-over, we have to ignore it.
Fixes #172191
Added:
Modified:
clang/lib/AST/ByteCode/EvalEmitter.cpp
clang/test/AST/ByteCode/builtin-constant-p.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 2ed5147a15491..cf3cc1b17133c 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -155,6 +155,8 @@ bool EvalEmitter::fallthrough(const LabelTy &Label) {
}
bool EvalEmitter::speculate(const CallExpr *E, const LabelTy &EndLabel) {
+ if (!isActive())
+ return true;
size_t StackSizeBefore = S.Stk.size();
const Expr *Arg = E->getArg(0);
if (!this->visit(Arg)) {
diff --git a/clang/test/AST/ByteCode/builtin-constant-p.cpp b/clang/test/AST/ByteCode/builtin-constant-p.cpp
index 315a907949c34..c6b074e403bed 100644
--- a/clang/test/AST/ByteCode/builtin-constant-p.cpp
+++ b/clang/test/AST/ByteCode/builtin-constant-p.cpp
@@ -148,3 +148,15 @@ static void foo(int i) __attribute__((__diagnose_if__(!__builtin_constant_p(i),
static void bar(int i) {
foo(15); // expected-error {{not constant}}
}
+
+namespace Inactive {
+ int foo() {
+ if ((__extension__(
+ 0 ? __extension__({ (1 ? 0 : (__builtin_constant_p("plane"))); })
+ : 0)) == 0) {
+ }
+
+ return 0;
+ }
+
+}
More information about the cfe-commits
mailing list