================ @@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName &Name) const { canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(), subst->getFinal(), subst->getIndex()); } + case TemplateName::DeducedTemplate: { + assert(IgnoreDeduced == false); + DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName(); + DefaultArguments DefArgs = DTS->getDefaultArguments(); + TemplateName Underlying = DTS->getUnderlying(); + + bool NonCanonical = false; + TemplateName CanonUnderlying = + getCanonicalTemplateName(Underlying, /*IgnoreDeduced=*/true); + NonCanonical |= CanonUnderlying != Underlying; + auto CanonArgs = + getCanonicalTemplateArguments(*this, DefArgs.Args, NonCanonical); + { + unsigned NumArgs = CanonArgs.size() - 1; + auto handleParamDefArg = [&](const TemplateArgument &ParamDefArg, + unsigned I) { + auto CanonParamDefArg = getCanonicalTemplateArgument(ParamDefArg); + TemplateArgument &CanonDefArg = CanonArgs[I]; + if (CanonDefArg.structurallyEquals(CanonParamDefArg)) + return; + if (I == NumArgs) + CanonArgs.pop_back(); + NonCanonical = true; + }; + auto handleParam = [&](auto *TP, int I) -> bool { + if (!TP->hasDefaultArgument()) + return true; + handleParamDefArg(TP->getDefaultArgument().getArgument(), I); + return false; + }; + + ArrayRef<NamedDecl *> Params = CanonUnderlying.getAsTemplateDecl() + ->getTemplateParameters() + ->asArray(); + assert(CanonArgs.size() <= Params.size()); + for (int I = NumArgs; I >= 0; --I) { ---------------- mizvekov wrote:
The code is correct, but the variable name is not right. Should have been `LastArgIndex` or some such. https://github.com/llvm/llvm-project/pull/94981 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits