[clang] [Clang][Sema] Push an evaluation context for type constraints (PR #93945)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 04:26:11 PDT 2024


================
@@ -5004,6 +5004,20 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, const AutoType &Type,
     return true;
   MultiLevelTemplateArgumentList MLTAL(Concept, CanonicalConverted,
                                        /*Final=*/false);
+  // Build up an EvaluationContext with an ImplicitConceptSpecializationDecl so
+  // that the template arguments of the constraint can be preserved. For
+  // example:
+  //
+  //  template <class T>
+  //  concept C = []<D U = void>() { return true; }();
+  //
+  // We need the argument for T while evaluating type constraint D in
+  // building the CallExpr to the lambda.
+  EnterExpressionEvaluationContext EECtx(
+      S, Sema::ExpressionEvaluationContext::ConstantEvaluated,
----------------
zyn0217 wrote:

Good question. Honestly, I copied the line from `Sema::CheckConceptTemplateId`:

https://github.com/llvm/llvm-project/blob/f34dedbf44a0578430f81de94f294f4474fee0fb/clang/lib/Sema/SemaTemplate.cpp#L5662-L5670

I'll look into the details later and hopefully get back with an answer. (Of course I'd appreciate it if @erichkeane could beat me to it.)

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


More information about the cfe-commits mailing list