[clang] [C++20] [Modules] Don't mark variables from other modules as constant if its initializer is not constant (PR #93530)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 28 03:49:40 PDT 2024
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 ea20647023f7bb110e8a198485727458684c43c6 778205df51376ddd38253b2ce5bab9dcab512774 -- clang/test/Modules/pr93497.cppm clang/lib/CodeGen/CodeGenModule.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 5596a6708e..256825fde0 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5491,10 +5491,10 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
emitter->finalize(GV);
// If it is safe to mark the global 'constant', do so now.
- GV->setConstant(!NeedsGlobalCtor && !NeedsGlobalDtor &&
- (!IsDefinitionAvailableExternally ||
- D->hasConstantInitialization()) &&
- D->getType().isConstantStorage(getContext(), true, true));
+ GV->setConstant(
+ !NeedsGlobalCtor && !NeedsGlobalDtor &&
+ (!IsDefinitionAvailableExternally || D->hasConstantInitialization()) &&
+ D->getType().isConstantStorage(getContext(), true, true));
// If it is in a read-only section, mark it 'constant'.
if (const SectionAttr *SA = D->getAttr<SectionAttr>()) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/93530
More information about the cfe-commits
mailing list