[clang] [clang] Emit initializers for static const/constexpr variables once they're met (PR #156933)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 4 10:25:34 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- clang/test/CodeGenCXX/static-constexpr-in-consteval.cpp clang/lib/CodeGen/CGDecl.cpp clang/test/CodeGenCXX/pr47636.cpp clang/test/CodeGenCXX/reference-init.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index da030f4c7..45e29d0b5 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -294,8 +294,8 @@ llvm::Constant *CodeGenModule::getOrCreateStaticVarDecl(
   }
 
   llvm::GlobalVariable *GV = new llvm::GlobalVariable(
-      getModule(), Init->getType(), Ty.isConstant(getContext()), Linkage, Init, Name,
-      nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
+      getModule(), Init->getType(), Ty.isConstant(getContext()), Linkage, Init,
+      Name, nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
 
   if (Emitter)
     Emitter->finalize(GV);

``````````

</details>


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


More information about the cfe-commits mailing list