================
@@ -690,6 +690,23 @@ SmallVector<unsigned> 
TemplateParamsReferencedInTemplateArgumentList(
   SemaRef.MarkUsedTemplateParameters(
       DeducedArgs, TemplateParamsList->getDepth(), ReferencedTemplateParams);
 
+  auto MarkDefaultArgs = [&](auto *Param) {
+    if (!Param || !Param->hasDefaultArgument())
+      return;
+    SemaRef.MarkUsedTemplateParameters(
+        Param->getDefaultArgument().getArgument(),
+        TemplateParamsList->getDepth(), ReferencedTemplateParams);
+  };
+
+  for (unsigned Index = 0; Index < TemplateParamsList->size(); ++Index) {
+    if (!ReferencedTemplateParams[Index])
+      continue;
+    auto *Param = TemplateParamsList->getParam(Index);
+    MarkDefaultArgs(dyn_cast<TemplateTypeParmDecl>(Param));
+    MarkDefaultArgs(dyn_cast<NonTypeTemplateParmDecl>(Param));
+    MarkDefaultArgs(dyn_cast<TemplateTemplateParmDecl>(Param));
+  }
+
----------------
zyn0217 wrote:

> For example, it seems this will mark default arguments as used even if the 
> corresponding parameter has a deduced argument.

That might not be a big deal, because as long as the default parameter doesn't 
end up in the argument list of RHS, it shouldn't affect the template argument 
deduction running against on the synthesized deductions guides -- we don't need 
to CodeGen for deduction guides nor it has to be fully instantiated for all of 
its parameters, right?

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

Reply via email to