[clang] [clang][bytecode] Only override constant-context state if we have an EvalEmitter (PR #211475)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 23 00:04:45 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/211475
This does not make sense when emitting bytecode, as the bytecode would just contain a `PushCC`/`PopCC` pair with nothing in between.
>From 794e2411660691586b76b603dc63539b386b94a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 23 Jul 2026 09:02:24 +0200
Subject: [PATCH] CC
---
clang/lib/AST/ByteCode/Compiler.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 35667a9132680..337f65d02ef50 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -8276,12 +8276,16 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
bool IsConstexprUnknown = true) -> bool {
llvm::SaveAndRestore CURS(this->VariablesAreConstexprUnknown,
IsConstexprUnknown);
- if (!this->emitPushCC(VD->hasConstantInitialization(), E))
- return false;
+ if constexpr (std::is_same_v<Emitter, EvalEmitter>) {
+ if (!this->emitPushCC(VD->hasConstantInitialization(), E))
+ return false;
+ }
auto VarState = this->visitDecl(VD);
- if (!this->emitPopCC(E))
- return false;
+ if constexpr (std::is_same_v<Emitter, EvalEmitter>) {
+ if (!this->emitPopCC(E))
+ return false;
+ }
if (VarState.notCreated())
return true;
More information about the cfe-commits
mailing list