[clang] [clang][bytecode] Check isActive() in EvalEmitter::speculate() (PR #174183)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 2 00:02:33 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
If this opcode is being jumped-over, we have to ignore it.
Fixes #<!-- -->172191
---
Full diff: https://github.com/llvm/llvm-project/pull/174183.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+2)
- (modified) clang/test/AST/ByteCode/builtin-constant-p.cpp (+12)
``````````diff
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;
+ }
+
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/174183
More information about the cfe-commits
mailing list