diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 4363dda5c2df..a480f54394c6 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -623,6 +623,7 @@ public: /// EndParameterPack - Finish adding arguments from a parameter pack. void EndParameterPack(); + const TemplateArgument *getFlatArgumentList() const { return Args.data(); } TemplateArgument *getFlatArgumentList() { return Args.data(); } }; diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 962f0ce35f41..169ce8216c63 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1959,7 +1959,7 @@ public: bool CheckClassTemplatePartialSpecializationArgs( TemplateParameterList *TemplateParams, - const TemplateArgument *TemplateArgs, + const TemplateArgumentListBuilder &TemplateArgs, bool &MirrorsPrimaryTemplate); virtual DeclResult diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 00d8c769bd22..b2a82ed74d51 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2080,11 +2080,14 @@ Sema::CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate, /// \returns true if there was an error, false otherwise. bool Sema::CheckClassTemplatePartialSpecializationArgs( TemplateParameterList *TemplateParams, - const TemplateArgument *TemplateArgs, + const TemplateArgumentListBuilder &TemplateArgs, bool &MirrorsPrimaryTemplate) { // FIXME: the interface to this function will have to change to // accommodate variadic templates. MirrorsPrimaryTemplate = true; + + const TemplateArgument *ArgList = TemplateArgs.getFlatArgumentList(); + for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) { // Determine whether the template argument list of the partial // specialization is identical to the implicit argument list of @@ -2094,7 +2097,7 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs( if (TemplateTypeParmDecl *TTP = dyn_cast(TemplateParams->getParam(I))) { if (Context.getCanonicalType(Context.getTypeDeclType(TTP)) != - Context.getCanonicalType(TemplateArgs[I].getAsType())) + Context.getCanonicalType(ArgList[I].getAsType())) MirrorsPrimaryTemplate = false; } else if (TemplateTemplateParmDecl *TTP = dyn_cast( @@ -2103,10 +2106,10 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs( // Expression storage for template template parameters. TemplateTemplateParmDecl *ArgDecl = dyn_cast_or_null( - TemplateArgs[I].getAsDecl()); + ArgList[I].getAsDecl()); if (!ArgDecl) if (DeclRefExpr *DRE - = dyn_cast_or_null(TemplateArgs[I].getAsExpr())) + = dyn_cast_or_null(ArgList[I].getAsExpr())) ArgDecl = dyn_cast(DRE->getDecl()); if (!ArgDecl || @@ -2122,7 +2125,7 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs( continue; } - Expr *ArgExpr = TemplateArgs[I].getAsExpr(); + Expr *ArgExpr = ArgList[I].getAsExpr(); if (!ArgExpr) { MirrorsPrimaryTemplate = false; continue; @@ -2281,7 +2284,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK, // template. TemplateArgumentListBuilder ConvertedTemplateArgs(Context); if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, LAngleLoc, - &TemplateArgs[0], TemplateArgs.size(), + TemplateArgs.data(), TemplateArgs.size(), RAngleLoc, ConvertedTemplateArgs)) return true; @@ -2296,7 +2299,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK, bool MirrorsPrimaryTemplate; if (CheckClassTemplatePartialSpecializationArgs( ClassTemplate->getTemplateParameters(), - ConvertedTemplateArgs.getFlatArgumentList(), + ConvertedTemplateArgs, MirrorsPrimaryTemplate)) return true; @@ -2456,7 +2459,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK, // template arguments in the specialization. QualType WrittenTy = Context.getTemplateSpecializationType(Name, - &TemplateArgs[0], + TemplateArgs.data(), TemplateArgs.size(), Context.getTypeDeclType(Specialization)); Specialization->setTypeAsWritten(WrittenTy);