[clang] 6f0a627 - [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (#122875)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 20 00:56:07 PST 2025


Author: Younan Zhang
Date: 2025-01-20T16:56:04+08:00
New Revision: 6f0a627dd3c21209ea45f355ecedd15d739418a1

URL: https://github.com/llvm/llvm-project/commit/6f0a627dd3c21209ea45f355ecedd15d739418a1
DIFF: https://github.com/llvm/llvm-project/commit/6f0a627dd3c21209ea45f355ecedd15d739418a1.diff

LOG: [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (#122875)

We should have been checking desugar() for the type of the right-hand
side of a typedef declaration, instead of using getCanonicalType(),
which points to the end of the type alias chain.

Fixes https://github.com/llvm/llvm-project/issues/122417

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/Sema/TreeTransform.h
    clang/test/SemaCXX/fold_lambda_with_variadics.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b02ac467cd3a22..2f7b9227386961 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -860,7 +860,7 @@ Bug Fixes to C++ Support
   module imports in those situations. (#GH60336)
 - Fix init-capture packs having a size of one before being instantiated. (#GH63677)
 - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
-  (#GH99877).
+  (#GH99877), (#GH122417).
 - Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
 - Fixed an assertion failure when selecting a function from an overload set that includes a
   specialization of a conversion function template.

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4fae2ccb5f6d0a..7dc88a1ae23b98 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -8499,7 +8499,7 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
             getSema()
                 .getASTContext()
                 .getTypeDeclType(TD)
-                .getCanonicalType()
+                .getSingleStepDesugaredType(getSema().getASTContext())
                 ->containsUnexpandedParameterPack();
 
       if (auto *VD = dyn_cast<VarDecl>(Transformed))

diff  --git a/clang/test/SemaCXX/fold_lambda_with_variadics.cpp b/clang/test/SemaCXX/fold_lambda_with_variadics.cpp
index 2257a4c2d975a8..69572bea3664a7 100644
--- a/clang/test/SemaCXX/fold_lambda_with_variadics.cpp
+++ b/clang/test/SemaCXX/fold_lambda_with_variadics.cpp
@@ -7,6 +7,8 @@ struct identity {
   using type = T;
 };
 
+template <class> using ElementType = int;
+
 template <class = void> void f() {
 
   static_assert([]<class... Is>(Is... x) {
@@ -47,6 +49,10 @@ template <class = void> void f() {
     }(), ...);
   }(1, 2);
 
+  []<class... Is>(Is...) {
+    ([] { using T = ElementType<Is>; }(), ...);
+  }(1);
+
   [](auto ...y) {
     ([y] { }(), ...);
   }();


        


More information about the cfe-commits mailing list