[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 7 09:10:57 PDT 2024
================
@@ -6753,16 +6758,41 @@ ASTContext::getNameForTemplate(TemplateName Name,
case TemplateName::UsingTemplate:
return DeclarationNameInfo(Name.getAsUsingShadowDecl()->getDeclName(),
NameLoc);
+ case TemplateName::DeducedTemplate: {
+ DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+ return getNameForTemplate(DTS->getUnderlying(), NameLoc);
+ }
}
llvm_unreachable("bad template name kind!");
}
-TemplateName
-ASTContext::getCanonicalTemplateName(const TemplateName &Name) const {
+static const TemplateArgument *
+getDefaultTemplateArgumentOrNone(const NamedDecl *P) {
+ auto handleParam = [](auto *TP) -> const TemplateArgument * {
+ if (!TP->hasDefaultArgument())
+ return nullptr;
+ return &TP->getDefaultArgument().getArgument();
+ };
+ switch (P->getKind()) {
+ case NamedDecl::TemplateTypeParm:
+ return handleParam(cast<TemplateTypeParmDecl>(P));
+ case NamedDecl::NonTypeTemplateParm:
+ return handleParam(cast<NonTypeTemplateParmDecl>(P));
+ case NamedDecl::TemplateTemplateParm:
+ return handleParam(cast<TemplateTemplateParmDecl>(P));
+ default:
+ llvm_unreachable("Unexpected template parameter kind");
+ }
+}
----------------
cor3ntin wrote:
Not in this PR, but i wonder if we should have a base class for all these types
https://github.com/llvm/llvm-project/pull/94981
More information about the cfe-commits
mailing list