[clang] [Clang] Follow up to previous lambda-in-concept patch (PR #210381)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 22 03:32:55 PDT 2026


================
@@ -3761,13 +3761,17 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
   if (IsExpandedParameterPack)
     Param = NonTypeTemplateParmDecl::Create(
         SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(),
-        D->getDepth() - TemplateArgs.getNumSubstitutedLevels(),
+        D->getDepth() - (TemplateArgs.retainInnerDepths()
+                             ? 0
+                             : TemplateArgs.getNumSubstitutedLevels()),
         D->getPosition(), D->getIdentifier(), T, TSI,
         ExpandedParameterPackTypes, ExpandedParameterPackTypesAsWritten);
   else
     Param = NonTypeTemplateParmDecl::Create(
         SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(),
-        D->getDepth() - TemplateArgs.getNumSubstitutedLevels(),
+        D->getDepth() - (TemplateArgs.retainInnerDepths()
+                             ? 0
+                             : TemplateArgs.getNumSubstitutedLevels()),
----------------
zyn0217 wrote:

I explained the reason of retainInnerDepths() [there](https://github.com/llvm/llvm-project/pull/207966#discussion_r3627949315)

I would not attribute it as a workaround, since this is mainly equivalent to what we have [discussed](https://github.com/llvm/llvm-project/pull/195995#discussion_r3203180576) in the initial patch and this way handled more situations where the recursive instantiation is not initiated through TransformTemplateParameterList.


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


More information about the cfe-commits mailing list