[clang] [clang] CTAD alias: fix transformation for require-clause expr Part2. (PR #93533)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 10:13:03 PDT 2024


================
@@ -2840,8 +2841,22 @@ buildAssociatedConstraints(Sema &SemaRef, FunctionTemplateDecl *F,
 
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
     const auto &D = DeduceResults[Index];
-    if (D.isNull())
+    if (D.isNull()) { // non-deduced template parameters of f
+      auto TP = F->getTemplateParameters()->getParam(Index);
+      MultiLevelTemplateArgumentList Args;
+      Args.setKind(TemplateSubstitutionKind::Rewrite);
+      Args.addOuterTemplateArguments(TemplateArgsForBuildingRC);
+      // Rebuild the template parameter with updated depth and index.
+      NamedDecl *NewParam = transformTemplateParameter(
+          SemaRef, F->getDeclContext(), TP, Args,
+          /*NewIndex=*/UndeducedTemplateParameterStartIndex++,
+          getTemplateParameterDepth(TP) + AdjustDepth);
----------------
mizvekov wrote:

Took me a while to spot that one:
```suggestion
      NamedDecl *NewParam = transformTemplateParameter(
          SemaRef, F->getDeclContext(), TP, Args,
          /*NewIndex=*/UndeducedTemplateParameterStartIndex,
          getTemplateParameterDepth(TP) + AdjustDepth);
          UndeducedTemplateParameterStartIndex += 1;
```

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


More information about the cfe-commits mailing list