[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 18 09:40:09 PDT 2024


================
@@ -8385,14 +8385,19 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
     if (Transformed != D)
       DeclChanged = true;
 
-    if (LSI && isa<TypeDecl>(Transformed))
-      LSI->ContainsUnexpandedParameterPack |=
-          getSema()
-              .getASTContext()
-              .getTypeDeclType(cast<TypeDecl>(Transformed))
-              .getCanonicalType()
-              .getTypePtr()
-              ->containsUnexpandedParameterPack();
+    if (LSI) {
+      if (auto *TD = dyn_cast<TypeDecl>(Transformed))
+        LSI->ContainsUnexpandedParameterPack |=
+            getSema()
+                .getASTContext()
+                .getTypeDeclType(TD)
+                .getCanonicalType()
+                ->containsUnexpandedParameterPack();
+
+      if (auto *VD = dyn_cast<VarDecl>(Transformed))
+        LSI->ContainsUnexpandedParameterPack |=
+            VD->getType()->containsUnexpandedParameterPack();
+    }
----------------
cor3ntin wrote:

The more I see that sort of things, the more @zygoloid 's idea of tracking unexpanded packs lexically seems compelling.

we probably should have have a separate function for "does this declaration contains an unexpanded pack"


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


More information about the cfe-commits mailing list