[clang] [clang] Don't use `VarDecl` of local variables as `ManglingContextDecl` for lambdas (PR #179035)

via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 1 01:47:20 PST 2026


Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/179035 at github.com>


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 cppm,cpp -- clang/test/Modules/pr178893.cppm clang/lib/Sema/SemaLambda.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 cdefd6050..106633372 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -298,8 +298,8 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC) {
   // is a local variable, use the `DeclContext` containing the lambda expression
   // instead.
   if (VarDecl *Var = dyn_cast_or_null<VarDecl>(ManglingContextDecl);
-        Var && Var->isLocalVarDecl())
-      ManglingContextDecl = const_cast<Decl *>(cast<Decl>(DC));
+      Var && Var->isLocalVarDecl())
+    ManglingContextDecl = const_cast<Decl *>(cast<Decl>(DC));
 
   // Default arguments of member function parameters that appear in a class
   // definition, as well as the initializers of data members, receive special

``````````

</details>


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


More information about the cfe-commits mailing list