[clang] Fix lambda merging to apply to locally-parsed lambdas. (PR #215661)

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 13:59:41 PDT 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 h,cpp -- clang/test/Modules/lambda-merge-local.cpp clang/include/clang/AST/ASTContext.h clang/include/clang/Sema/ExternalSemaSource.h clang/include/clang/Sema/MultiplexExternalSemaSource.h clang/include/clang/Serialization/ASTReader.h clang/lib/Sema/MultiplexExternalSemaSource.cpp clang/lib/Sema/SemaLambda.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.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/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index 2437329e4..62d595243 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -560,8 +560,8 @@ void Sema::handleLambdaNumbering(
   // This lambda might redeclare a previous lambda if this is not the first
   // definition of the context declaration. We might have a definition from
   // another translation unit.
-  auto*& Slot = Context.getLambdaDeclarationsForMerging()[LambdaInfo];
-  if (auto* Previous = Slot) {
+  auto *&Slot = Context.getLambdaDeclarationsForMerging()[LambdaInfo];
+  if (auto *Previous = Slot) {
     Class->setPreviousDecl(Previous);
     makeMergedDefinitionVisible(Previous);
   } else {
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 7e0d47c3c..e24948f4f 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2961,7 +2961,7 @@ void ASTDeclMerger::mergeLambda(CXXRecordDecl *D, RedeclarableResult &Redecl,
   // one we already loaded.
   auto *&Slot = Reader.getContext().getLambdaDeclarationsForMerging()[{
       Context.getCanonicalDecl(), IndexInContext}];
-  if (TagDecl* PrevDecl = Slot)
+  if (TagDecl *PrevDecl = Slot)
     mergeRedeclarable(D, PrevDecl, Redecl);
   else
     Slot = D;

``````````

</details>


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


More information about the cfe-commits mailing list