[clang] 3fd07e3 - [clang][bytecode] Only override constant-context state if we have an EvalEmitter (#211475)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 25 23:14:32 PDT 2026


Author: Timm Baeder
Date: 2026-07-26T08:14:28+02:00
New Revision: 3fd07e32350c4f15a9377466ab4cffb042a1ecb7

URL: https://github.com/llvm/llvm-project/commit/3fd07e32350c4f15a9377466ab4cffb042a1ecb7
DIFF: https://github.com/llvm/llvm-project/commit/3fd07e32350c4f15a9377466ab4cffb042a1ecb7.diff

LOG: [clang][bytecode] Only override constant-context state if we have an EvalEmitter (#211475)

This does not make sense when emitting bytecode, as the bytecode would
just contain a `PushCC`/`PopCC` pair with nothing in between.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Compiler.cpp

Removed: 
    


################################################################################
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