[clang] [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (PR #122875)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 14 01:14:52 PST 2025
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/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
>From bda66af1a35a120ad017fcfa310d68e977629ce2 Mon Sep 17 00:00:00 2001
From: Younan Zhang <zyn7109 at gmail.com>
Date: Tue, 14 Jan 2025 16:49:41 +0800
Subject: [PATCH] [Clang] Correctly propagate type aliases' unexpanded flags up
to lambda
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.
---
clang/docs/ReleaseNotes.rst | 2 +-
clang/lib/Sema/TreeTransform.h | 2 +-
clang/test/SemaCXX/fold_lambda_with_variadics.cpp | 6 ++++++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 07a1a4195427d8..a5da6c9c88328c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -810,7 +810,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 4a3c739ecbeab8..79df5cf4f2bb56 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -8496,7 +8496,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