[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 24 10:16:15 PDT 2024
================
@@ -519,13 +571,45 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams,
return TemplateDeductionResult::Success;
}
- if (TemplateTemplateParmDecl *TempParam
- = dyn_cast<TemplateTemplateParmDecl>(ParamDecl)) {
+ if (auto *TempParam = dyn_cast<TemplateTemplateParmDecl>(ParamDecl)) {
// If we're not deducing at this depth, there's nothing to deduce.
if (TempParam->getDepth() != Info.getDeducedDepth())
return TemplateDeductionResult::Success;
- DeducedTemplateArgument NewDeduced(S.Context.getCanonicalTemplateName(Arg));
+ auto NewDeduced = DeducedTemplateArgument(Arg);
+ // Provisional resolution for CWG2398: If Arg is also a template template
+ // param, and it names a template specialization, then we deduce a
+ // synthesized template template parameter based on A, but using the TS's
+ // arguments as defaults.
+ if (auto *TempArg = dyn_cast_or_null<TemplateTemplateParmDecl>(
+ Arg.getAsTemplateDecl())) {
+ assert(Arg.getKind() == TemplateName::Template);
+ assert(!TempArg->isExpandedParameterPack());
+
+ TemplateParameterList *As = TempArg->getTemplateParameters();
+ if (DefaultArguments.size() != 0) {
+ assert(DefaultArguments.size() <= As->size());
+ SmallVector<NamedDecl *, 4> Params(As->size());
+ for (unsigned I = 0; I < DefaultArguments.size(); ++I)
+ Params[I] =
+ DeduceTemplateArguments(S, As->getParam(I), DefaultArguments[I]);
+ for (unsigned I = DefaultArguments.size(); I < As->size(); ++I)
+ Params[I] = As->getParam(I);
+ // FIXME: We could unique these, and also the parameters, but we don't
+ // expect programs to contain a large enough amount of these deductions
+ // for that to be worthwhile.
----------------
mizvekov wrote:
Yeah, doesn't affect identity. The results from deduction are assumed to be sugared, this was one of the changes I made to the deduction machinery back in 2021 or so.
Where identity is concerned, the types should be canonicalized, and we have a special step for canonicalizing template template parameters.
https://github.com/llvm/llvm-project/pull/89807
More information about the cfe-commits
mailing list