From: David Majnemer Date: Sun, 27 Dec 2015 07:16:27 +0000 (+0000) Subject: ArrayRef-ize TemplateParameterList. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3b6e588e0ac22c4bc82694db7c498733451df7c;p=clang ArrayRef-ize TemplateParameterList. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256463 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 8d62b23748..8657baeb92 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -68,15 +68,13 @@ protected: } TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, - NamedDecl **Params, unsigned NumParams, - SourceLocation RAngleLoc); + ArrayRef Params, SourceLocation RAngleLoc); public: static TemplateParameterList *Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, - NamedDecl **Params, - unsigned NumParams, + ArrayRef Params, SourceLocation RAngleLoc); /// \brief Iterates through the template parameters in this list. @@ -155,9 +153,9 @@ template class FixedSizeTemplateParameterListStorage { public: FixedSizeTemplateParameterListStorage(SourceLocation TemplateLoc, SourceLocation LAngleLoc, - NamedDecl **Params, + ArrayRef Params, SourceLocation RAngleLoc) - : List(TemplateLoc, LAngleLoc, Params, N, RAngleLoc) { + : List(TemplateLoc, LAngleLoc, Params, RAngleLoc) { // Because we're doing an evil layout hack above, have some // asserts, just to double-check everything is laid out like // expected. diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index e4c0fdbb70..b344b0687f 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -660,8 +660,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( nullptr, TemplateParameterList::Create(*this, SourceLocation(), SourceLocation(), - CanonParams.data(), - CanonParams.size(), + CanonParams, SourceLocation())); // Get the new insert position for the node we care about. diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 824cc18010..359db1ba81 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2144,7 +2144,7 @@ TemplateParameterList *ASTNodeImporter::ImportTemplateParameterList( return TemplateParameterList::Create(Importer.getToContext(), Importer.Import(Params->getTemplateLoc()), Importer.Import(Params->getLAngleLoc()), - ToParams.data(), ToParams.size(), + ToParams, Importer.Import(Params->getRAngleLoc())); } diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index 18a30b2f1c..de3ebd23ef 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -30,10 +30,10 @@ using namespace clang; TemplateParameterList::TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, - NamedDecl **Params, unsigned NumParams, + ArrayRef Params, SourceLocation RAngleLoc) : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc), - NumParams(NumParams), ContainsUnexpandedParameterPack(false) { + NumParams(Params.size()), ContainsUnexpandedParameterPack(false) { assert(this->NumParams == NumParams && "Too many template parameters"); for (unsigned Idx = 0; Idx < NumParams; ++Idx) { NamedDecl *P = Params[Idx]; @@ -54,14 +54,13 @@ TemplateParameterList::TemplateParameterList(SourceLocation TemplateLoc, } } -TemplateParameterList * -TemplateParameterList::Create(const ASTContext &C, SourceLocation TemplateLoc, - SourceLocation LAngleLoc, NamedDecl **Params, - unsigned NumParams, SourceLocation RAngleLoc) { - void *Mem = C.Allocate(totalSizeToAlloc(NumParams), +TemplateParameterList *TemplateParameterList::Create( + const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, + ArrayRef Params, SourceLocation RAngleLoc) { + void *Mem = C.Allocate(totalSizeToAlloc(Params.size()), llvm::alignOf()); return new (Mem) TemplateParameterList(TemplateLoc, LAngleLoc, Params, - NumParams, RAngleLoc); + RAngleLoc); } unsigned TemplateParameterList::getMinRequiredArguments() const { @@ -1212,7 +1211,7 @@ createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC) { // NamedDecl *P[2] = {T, N}; auto *TPL = TemplateParameterList::Create( - C, SourceLocation(), SourceLocation(), P, 2, SourceLocation()); + C, SourceLocation(), SourceLocation(), P, SourceLocation()); // template class IntSeq auto *TemplateTemplateParm = TemplateTemplateParmDecl::Create( @@ -1237,7 +1236,7 @@ createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC) { // template