[clang] [Clang] Transform lambda's constraints when instantiating parameter mapping (PR #195995)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Thu May 7 20:59:46 PDT 2026


================
@@ -1876,11 +1901,25 @@ namespace {
                               TemplateParameterList *OrigTPL)  {
       if (!OrigTPL || !OrigTPL->size()) return OrigTPL;
 
+      std::optional<MultiLevelTemplateArgumentList> OldMLTAL;
+      // We need to preserve the lambda depth in parameter mapping.
+      // Otherwise the template argument deduction would fail, if we reduced the
+      // depth too early.
+      if (SemaRef.inParameterMappingSubstitution() &&
+          getDepthAndIndex(OrigTPL->getParam(0)).first >=
+              TemplateArgs.getNumSubstitutedLevels())
+        OldMLTAL = ForgetSubstitution();
----------------
zyn0217 wrote:

the decl instantiator reduces the depth by getNumSubstitutedLevels(), I don't know how we can clamp MLTAL without forgetting the outer template arguments?

Are you concerning about associated type constraints getting untransformed, I guess?

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


More information about the cfe-commits mailing list