Skip to content

Commit 8562b2b

Browse files
committed
Drive-by fix for #132061 (comment)
1 parent 27a42c2 commit 8562b2b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,19 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) {
972972
return {Template, AliasRhsTemplateArgs};
973973
}
974974

975+
bool IsNonDeducedArgument(const TemplateArgument &TA) {
976+
// The following cases indicate the template argument is non-deducible:
977+
// 1. The result is null. E.g. When it comes from a default template
978+
// argument that doesn't appear in the alias declaration.
979+
// 2. The template parameter is a pack and that cannot be deduced from
980+
// the arguments within the alias declaration.
981+
// Non-deducible template parameters will persist in the transformed
982+
// deduction guide.
983+
return TA.isNull() ||
984+
(TA.getKind() == TemplateArgument::Pack &&
985+
llvm::any_of(TA.pack_elements(), IsNonDeducedArgument));
986+
}
987+
975988
// Build deduction guides for a type alias template from the given underlying
976989
// deduction guide F.
977990
FunctionTemplateDecl *

0 commit comments

Comments
 (0)