[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 22 03:53:37 PDT 2024
================
@@ -3207,6 +3241,59 @@ Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
return ::DeduceTemplateArguments(*this, Partial, TemplateArgs, Info);
}
+TemplateDeductionResult
+Sema::DeduceTemplateArgumentsFromType(TemplateDecl *TD, QualType FromType,
+ sema::TemplateDeductionInfo &Info) {
+ if (TD->isInvalidDecl())
+ return TemplateDeductionResult::Invalid;
+
+ QualType PType;
+ if (const auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
+ // Use the InjectedClassNameType.
+ PType = Context.getTypeDeclType(CTD->getTemplatedDecl());
+ } else if (const auto *AliasTemplate = dyn_cast<TypeAliasTemplateDecl>(TD)) {
+ PType = AliasTemplate->getTemplatedDecl()
+ ->getUnderlyingType()
+ .getCanonicalType();
+ } else {
+ // FIXME: emit a diagnostic, we only only support alias and class templates.
----------------
hokein wrote:
It turns out we will never hit other cases in this code path (we will reject the var/function templates when parsing the type trait expr). I changed it to `assert`.
https://github.com/llvm/llvm-project/pull/89358
More information about the cfe-commits
mailing list