[clang] [clang][CodeGen] Diagnose deferred definitions with identical mangled names (PR #248930)

via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 5 08:57:02 PST 2026


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 c,h,cpp -- clang/test/CodeGen/asm-label-duplicate-definition.c clang/test/Interpreter/failed-input-drops-ir.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ModuleBuilder.cpp clang/lib/Interpreter/IncrementalAction.cpp clang/lib/Interpreter/IncrementalAction.h clang/lib/Interpreter/IncrementalParser.cpp clang/test/CodeGenCXX/duplicate-mangled-name.cpp clang/unittests/Interpreter/InterpreterTest.cpp --diff_from_common_commit
``````````

: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/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 347dbe3dc..d69c21678 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5068,11 +5068,11 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
 
     if (PrevD != CurD &&
         (!PrevFD || (!PrevFD->isMultiVersion() &&
-                    getContext().GetGVALinkageForFunction(PrevFD) !=
-                    GVA_AvailableExternally )) &&
+                     getContext().GetGVALinkageForFunction(PrevFD) !=
+                         GVA_AvailableExternally)) &&
         (!CurFD || (!CurFD->isMultiVersion() &&
                     getContext().GetGVALinkageForFunction(CurFD) !=
-                    GVA_AvailableExternally))) {
+                        GVA_AvailableExternally))) {
       if (DiagnosedConflictingDefinitions.insert(GD).second) {
         Diags.Report(Global->getLocation(), diag::err_duplicate_mangled_name)
             << MangledName;

``````````

</details>


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


More information about the cfe-commits mailing list