https://github.com/redcode updated 
https://github.com/llvm/llvm-project/pull/232986

From cf6bc51b6c05b752d249c32ceb6a066fa6daffad Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Sat, 17 Oct 2026 01:50:04 +0200
Subject: [PATCH 1/9] [analyzer] Fix crash in PaddingChecker on dependent field
 types

---
 clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp | 6 ++++++
 clang/test/Analysis/padding_dependent.cpp            | 7 +++++++
 2 files changed, 13 insertions(+)
 create mode 100644 clang/test/Analysis/padding_dependent.cpp

diff --git a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
index c8d7b6555f3f4..8fbd1831f9175 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -178,6 +178,12 @@ class PaddingChecker : public 
Checker<check::ASTDecl<TranslationUnitDecl>> {
       QualType Ty = FD->getType();
       if (Ty->isIncompleteArrayType())
         return true;
+      // Dependent field types have no known layout, so we can't compute the
+      // padding of the enclosing record. This can happen for lambda captures
+      // in a dependent context, e.g. an init-capture of a forwarding reference
+      // inside a noexcept specifier.
+      if (Ty->isDependentType())
+        return true;
       return false;
     };
 
diff --git a/clang/test/Analysis/padding_dependent.cpp 
b/clang/test/Analysis/padding_dependent.cpp
new file mode 100644
index 0000000000000..ea337d1337950
--- /dev/null
+++ b/clang/test/Analysis/padding_dependent.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_analyze_cc1 -std=c++20 -analyzer-checker=optin.performance 
-verify %s
+
+// The static analyzer must not crash when computing the layout of a lambda
+// closure type with a dependent init-capture inside a noexcept specifier.
+// https://github.com/llvm/llvm-project/issues/232874
+// expected-no-diagnostics
+void crasher(auto&& fn) noexcept(noexcept([_ = fn] {})) {}

From 81cd7c09aca49ef26ca369734fb57d8b951a1723 Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Sat, 17 Oct 2026 17:51:57 +0200
Subject: [PATCH 2/9] Add FIXME to `Sema::ActOnLambdaExpressionAfterIntroducer`
 and reword comment in `PaddingChecker::shouldSkipDecl`

---
 clang/lib/Sema/SemaLambda.cpp                        | 8 ++++++++
 clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp | 9 +++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index 0c9a92cdd0c32..3f77c57223a46 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1141,6 +1141,14 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
 
   // Determine if we're within a context where we know that the lambda will
   // be dependent, because there are template parameters in scope.
+  //
+  // FIXME: A lambda in the noexcept specifier of an abbreviated function
+  // template (e.g. `auto&&`) is not marked dependent, even though it captures
+  // a dependent entity. Could this be because the implicit template parameter
+  // is not in scope while the specifier is parsed, leaving the lambda's
+  // dependency kind as LDK_Unknown? See:
+  // * https://github.com/llvm/llvm-project/issues/232874
+  // * https://github.com/llvm/llvm-project/issues/233102
   CXXRecordDecl::LambdaDependencyKind LambdaDependencyKind =
       CXXRecordDecl::LDK_Unknown;
   if (CurScope->getTemplateParamParent() != nullptr) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
index 8fbd1831f9175..d444a039d39a7 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -178,10 +178,11 @@ class PaddingChecker : public 
Checker<check::ASTDecl<TranslationUnitDecl>> {
       QualType Ty = FD->getType();
       if (Ty->isIncompleteArrayType())
         return true;
-      // Dependent field types have no known layout, so we can't compute the
-      // padding of the enclosing record. This can happen for lambda captures
-      // in a dependent context, e.g. an init-capture of a forwarding reference
-      // inside a noexcept specifier.
+      // Defensive backstop: a lambda closure type can be left non-dependent
+      // due to a bug in Sema (see SemaLambda.cpp), leaving a field of a bare
+      // dependent type whose layout cannot be computed. See:
+      // * https://github.com/llvm/llvm-project/issues/232874
+      // * https://github.com/llvm/llvm-project/issues/233102
       if (Ty->isDependentType())
         return true;
       return false;

From cb4bfdcdf7491ed951ad6e4c1d00f16b7f9a5c12 Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Sat, 17 Oct 2026 20:51:09 +0200
Subject: [PATCH 3/9] Move `clang/test/Analysis/padding_dependent.cpp` into
 `clang/test/Analysis/padding_cpp.cpp`

---
 clang/test/Analysis/padding_cpp.cpp       | 3 ++-
 clang/test/Analysis/padding_dependent.cpp | 7 -------
 2 files changed, 2 insertions(+), 8 deletions(-)
 delete mode 100644 clang/test/Analysis/padding_dependent.cpp

diff --git a/clang/test/Analysis/padding_cpp.cpp 
b/clang/test/Analysis/padding_cpp.cpp
index f0e8beacda763..603cb21c89ea3 100644
--- a/clang/test/Analysis/padding_cpp.cpp
+++ b/clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// RUN: %clang_analyze_cc1 -std=c++20 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
@@ -200,3 +200,4 @@ struct GlobalsForLambda { // no-warning
 // expected-warning@+1{{Excessive padding in 'class (lambda}}
 auto lambda1 = [ c1 = G.c1, i = G.i, c2 = G.c2 ]{};
 auto lambda2 = [ i = G.i, c1 = G.c1, c2 = G.c2 ]{}; // no-warning
+void crasher(auto&& fn) noexcept(noexcept([_ = fn] {})) {} // no-crash: gh 
#232874
diff --git a/clang/test/Analysis/padding_dependent.cpp 
b/clang/test/Analysis/padding_dependent.cpp
deleted file mode 100644
index ea337d1337950..0000000000000
--- a/clang/test/Analysis/padding_dependent.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clang_analyze_cc1 -std=c++20 -analyzer-checker=optin.performance 
-verify %s
-
-// The static analyzer must not crash when computing the layout of a lambda
-// closure type with a dependent init-capture inside a noexcept specifier.
-// https://github.com/llvm/llvm-project/issues/232874
-// expected-no-diagnostics
-void crasher(auto&& fn) noexcept(noexcept([_ = fn] {})) {}

From 7130255c173b3395f7fed86272990b4b1bce629c Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Sat, 17 Oct 2026 22:29:37 +0200
Subject: [PATCH 4/9] [AST] Add unit test for lambda not marked dependent in
 `noexcept` specifier

---
 clang/unittests/AST/CMakeLists.txt           |  1 +
 clang/unittests/AST/LambdaDependencyTest.cpp | 40 ++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 clang/unittests/AST/LambdaDependencyTest.cpp

diff --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index 8e4cb5af59c92..7ea5c9b501ef6 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_unittest(ASTTests
   DeclTest.cpp
   EvaluateAsRValueTest.cpp
   ExternalASTSourceTest.cpp
+  LambdaDependencyTest.cpp
   NamedDeclPrinterTest.cpp
   ProfilingTest.cpp
   QualTypeNamesTest.cpp
diff --git a/clang/unittests/AST/LambdaDependencyTest.cpp 
b/clang/unittests/AST/LambdaDependencyTest.cpp
new file mode 100644
index 0000000000000..a32b6606e8c15
--- /dev/null
+++ b/clang/unittests/AST/LambdaDependencyTest.cpp
@@ -0,0 +1,40 @@
+//===- unittests/AST/LambdaDependencyTest.cpp --- Lambda dependency tests 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DeclMatcher.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+using namespace clang::tooling;
+
+namespace {
+
+TEST(LambdaDependencyTest, NoexceptSpecifierOfAbbreviatedFunctionTemplate) {
+  auto AST = buildASTFromCodeWithArgs(
+      "void f(auto&& fn) noexcept(noexcept([_ = fn] {})) {}",
+      /*Args=*/{"-std=c++20"});
+  ASSERT_TRUE(AST);
+
+  FirstDeclMatcher<CXXRecordDecl> Matcher;
+  auto *Closure = Matcher.match(AST->getASTContext().getTranslationUnitDecl(),
+                                cxxRecordDecl(isLambda()));
+  ASSERT_NE(nullptr, Closure);
+
+  // FIXME: This documents a flawed behavior: the closure type of a lambda that
+  // captures a dependent entity is not marked dependent, even though it should
+  // be.
+  // See: https://github.com/llvm/llvm-project/issues/233102
+  EXPECT_FALSE(Closure->isDependentType());
+}
+
+} // namespace

From e180c1c769324cf6d70273b6bf71ac52907d9fe9 Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Sat, 17 Oct 2026 22:38:44 +0200
Subject: [PATCH 5/9] Remove defensive backstop from
 `PaddingChecker::shouldSkipDecl`

---
 clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
index d444a039d39a7..c8d7b6555f3f4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -178,13 +178,6 @@ class PaddingChecker : public 
Checker<check::ASTDecl<TranslationUnitDecl>> {
       QualType Ty = FD->getType();
       if (Ty->isIncompleteArrayType())
         return true;
-      // Defensive backstop: a lambda closure type can be left non-dependent
-      // due to a bug in Sema (see SemaLambda.cpp), leaving a field of a bare
-      // dependent type whose layout cannot be computed. See:
-      // * https://github.com/llvm/llvm-project/issues/232874
-      // * https://github.com/llvm/llvm-project/issues/233102
-      if (Ty->isDependentType())
-        return true;
       return false;
     };
 

From 5485c857fe1a8d6d19e3b0abf2927cfb6c7c0c5f Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Sat, 17 Oct 2026 22:47:26 +0200
Subject: [PATCH 6/9] Update FIXME in
 `Sema::ActOnLambdaExpressionAfterIntroducer`

---
 clang/lib/Sema/SemaLambda.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index 3f77c57223a46..db741639c8982 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1147,6 +1147,7 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   // a dependent entity. Could this be because the implicit template parameter
   // is not in scope while the specifier is parsed, leaving the lambda's
   // dependency kind as LDK_Unknown? See:
+  // * clang/unittests/AST/LambdaDependencyTest.cpp
   // * https://github.com/llvm/llvm-project/issues/232874
   // * https://github.com/llvm/llvm-project/issues/233102
   CXXRecordDecl::LambdaDependencyKind LambdaDependencyKind =

From f0ff158e5e74d8cac80c7c7ea5726e045579aedd Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Sun, 18 Oct 2026 00:11:48 +0200
Subject: [PATCH 7/9] Revert changes in `clang/test/Analysis/padding_cpp.cpp`

---
 clang/test/Analysis/padding_cpp.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/test/Analysis/padding_cpp.cpp 
b/clang/test/Analysis/padding_cpp.cpp
index 603cb21c89ea3..f0e8beacda763 100644
--- a/clang/test/Analysis/padding_cpp.cpp
+++ b/clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -std=c++20 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
@@ -200,4 +200,3 @@ struct GlobalsForLambda { // no-warning
 // expected-warning@+1{{Excessive padding in 'class (lambda}}
 auto lambda1 = [ c1 = G.c1, i = G.i, c2 = G.c2 ]{};
 auto lambda2 = [ i = G.i, c1 = G.c1, c2 = G.c2 ]{}; // no-warning
-void crasher(auto&& fn) noexcept(noexcept([_ = fn] {})) {} // no-crash: gh 
#232874

From 9b63b281a1e1ee880af3e48790012efc9379461d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Sainz=20de=20Baranda=20y=20Go=C3=B1i?=
 <[email protected]>
Date: Mon, 19 Oct 2026 20:10:29 +0200
Subject: [PATCH 8/9] Apply suggestions from code review in
 `clang/lib/Sema/SemaLambda.cpp`

Co-authored-by: Corentin Jabot <[email protected]>
---
 clang/lib/Sema/SemaLambda.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index db741639c8982..7b11a219678dc 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1143,10 +1143,8 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   // be dependent, because there are template parameters in scope.
   //
   // FIXME: A lambda in the noexcept specifier of an abbreviated function
-  // template (e.g. `auto&&`) is not marked dependent, even though it captures
-  // a dependent entity. Could this be because the implicit template parameter
-  // is not in scope while the specifier is parsed, leaving the lambda's
-  // dependency kind as LDK_Unknown? See:
+  // template (e.g. `auto&&`) is not marked dependent when it captures
+  // a dependent entity. See:
   // * clang/unittests/AST/LambdaDependencyTest.cpp
   // * https://github.com/llvm/llvm-project/issues/232874
   // * https://github.com/llvm/llvm-project/issues/233102

From edee9019d9ddc8751fa2fc1e2985bc950fc3ba11 Mon Sep 17 00:00:00 2001
From: redcode <[email protected]>
Date: Mon, 19 Oct 2026 20:57:40 +0200
Subject: [PATCH 9/9] Re-run CI


_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to