[clang] [clang] Fix static local variables in consteval functions (PR #156933)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 12 07:43:08 PDT 2025


================
@@ -4461,8 +4461,14 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) {
     return EmitGlobalFunctionDefinition(GD, GV);
   }
 
-  if (const auto *VD = dyn_cast<VarDecl>(D))
+  if (const auto *VD = dyn_cast<VarDecl>(D)) {
+    if (VD->isStaticLocal() && !getContext().shouldExternalize(D)) {
----------------
rjmccall wrote:

Alright, I'm happy with that. Just leave a comment explaining what's going on to the best of your ability, please.

https://github.com/llvm/llvm-project/pull/156933


More information about the cfe-commits mailing list