================
@@ -2446,40 +2446,14 @@ 
TemplateInstantiator::TransformSubstNonTypeTemplateParmExpr(
     SubstReplacement = TransformExpr(E->getReplacement());
   if (SubstReplacement.isInvalid())
     return true;
-  QualType SubstType = TransformType(E->getParameterType(getSema().Context));
-  if (SubstType.isNull())
-    return true;
-  // The type may have been previously dependent and not now, which means we
-  // might have to implicit cast the argument to the new type, for example:
-  // template<auto T, decltype(T) U>
-  // concept C = sizeof(U) == 4;
-  // void foo() requires C<2, 'a'> { }
-  // When normalizing foo(), we first form the normalized constraints of C:
-  // AtomicExpr(sizeof(U) == 4,
-  //            U=SubstNonTypeTemplateParmExpr(Param=U,
-  //                                           Expr=DeclRef(U),
-  //                                           Type=decltype(T)))
-  // Then we substitute T = 2, U = 'a' into the parameter mapping, and need to
-  // produce:
-  // AtomicExpr(sizeof(U) == 4,
-  //            U=SubstNonTypeTemplateParmExpr(Param=U,
-  //                                           Expr=ImpCast(
-  //                                               decltype(2),
-  //                                               SubstNTTPE(Param=U, 
Expr='a',
-  //                                                          Type=char)),
-  //                                           Type=decltype(2)))
-  // The call to CheckTemplateArgument here produces the ImpCast.
-  TemplateArgument SugaredConverted, CanonicalConverted;
-  if (SemaRef
-          .CheckTemplateArgument(E->getParameter(), SubstType,
-                                 SubstReplacement.get(), SugaredConverted,
-                                 CanonicalConverted,
-                                 /*StrictCheck=*/false, Sema::CTAK_Specified)
-          .isInvalid())
+  auto *Param = cast_or_null<NonTypeTemplateParmDecl>(
+      TransformDecl(E->getNameLoc(), E->getParameter()));
----------------
zyn0217 wrote:

Sorry for not being very specific hours ago, it took me some time to remember 
what actual problem it was (we switched to Rewrite mode in June)

Let me repeat the example
```cpp
template<auto Q> concept C = Q.template operator()<float>();
template<class> concept E = C<[]<class Ty>{ return false; }>;
static_assert(!E<int>);
```

For Q, we built a parameter mapping with the dependent lambda expression and 
hence `E->getParameter()` being dependent.

Before constraint evaluation, we would instantiate the parameter mappings with 
template arguments which results us being here for that purpose.

At line 2446, we transformed that dependent lambda expression into a 
non-dependent one, and at here we will transform that parameter type, which is 
unfortunately the type of the original lambda expression, i.e. a dependent 
RecordType.

And since we use a unique instantiation scope for lambdas, we will not have the 
instantiated type here and thus we will still have dependent expressions for 
evaluator.

So I think we need another workaround here, as in 
https://github.com/cor3ntin/llvm-project/pull/60, before you fix the lambda 
dependency issue in the end.

https://github.com/llvm/llvm-project/pull/158541
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to