r274475 - [AST] Use ArrayRef in more interfaces
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 3 14:17:52 PDT 2016
Author: majnemer
Date: Sun Jul 3 16:17:51 2016
New Revision: 274475
URL: http://llvm.org/viewvc/llvm-project?rev=274475&view=rev
Log:
[AST] Use ArrayRef in more interfaces
ArrayRef is a little better than passing around a pointer/length pair.
No functional change is intended.
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=274475&r1=274474&r2=274475&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Sun Jul 3 16:17:51 2016
@@ -184,7 +184,7 @@ class TemplateArgumentList final
// Constructs an instance with an internal Argument list, containing
// a copy of the Args array. (Called by CreateCopy)
- TemplateArgumentList(const TemplateArgument *Args, unsigned NumArgs);
+ TemplateArgumentList(ArrayRef<TemplateArgument> Args);
public:
/// \brief Type used to indicate that the template argument list itself is a
@@ -194,16 +194,14 @@ public:
/// \brief Create a new template argument list that copies the given set of
/// template arguments.
static TemplateArgumentList *CreateCopy(ASTContext &Context,
- const TemplateArgument *Args,
- unsigned NumArgs);
+ ArrayRef<TemplateArgument> Args);
/// \brief Construct a new, temporary template argument list on the stack.
///
/// The template argument list does not own the template arguments
/// provided.
- explicit TemplateArgumentList(OnStackType, const TemplateArgument *Args,
- unsigned NumArgs)
- : Arguments(Args), NumArguments(NumArgs) {}
+ explicit TemplateArgumentList(OnStackType, ArrayRef<TemplateArgument> Args)
+ : Arguments(Args.data()), NumArguments(Args.size()) {}
/// \brief Produces a shallow copy of the given template argument list.
///
@@ -1583,8 +1581,7 @@ protected:
DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
ClassTemplateSpecializationDecl *PrevDecl);
explicit ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
@@ -1594,8 +1591,7 @@ public:
Create(ASTContext &Context, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
ClassTemplateSpecializationDecl *PrevDecl);
static ClassTemplateSpecializationDecl *
CreateDeserialized(ASTContext &C, unsigned ID);
@@ -1811,8 +1807,7 @@ class ClassTemplatePartialSpecialization
SourceLocation IdLoc,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
const ASTTemplateArgumentListInfo *ArgsAsWritten,
ClassTemplatePartialSpecializationDecl *PrevDecl);
@@ -1827,8 +1822,7 @@ public:
SourceLocation StartLoc, SourceLocation IdLoc,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
const TemplateArgumentListInfo &ArgInfos,
QualType CanonInjectedType,
ClassTemplatePartialSpecializationDecl *PrevDecl);
@@ -2442,8 +2436,8 @@ protected:
SourceLocation StartLoc, SourceLocation IdLoc,
VarTemplateDecl *SpecializedTemplate,
QualType T, TypeSourceInfo *TInfo,
- StorageClass S, const TemplateArgument *Args,
- unsigned NumArgs);
+ StorageClass S,
+ ArrayRef<TemplateArgument> Args);
explicit VarTemplateSpecializationDecl(Kind DK, ASTContext &Context);
@@ -2451,8 +2445,8 @@ public:
static VarTemplateSpecializationDecl *
Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
- TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args,
- unsigned NumArgs);
+ TypeSourceInfo *TInfo, StorageClass S,
+ ArrayRef<TemplateArgument> Args);
static VarTemplateSpecializationDecl *CreateDeserialized(ASTContext &C,
unsigned ID);
@@ -2655,7 +2649,7 @@ class VarTemplatePartialSpecializationDe
ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, TemplateParameterList *Params,
VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
- StorageClass S, const TemplateArgument *Args, unsigned NumArgs,
+ StorageClass S, ArrayRef<TemplateArgument> Args,
const ASTTemplateArgumentListInfo *ArgInfos);
VarTemplatePartialSpecializationDecl(ASTContext &Context)
@@ -2668,8 +2662,8 @@ public:
Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, TemplateParameterList *Params,
VarTemplateDecl *SpecializedTemplate, QualType T,
- TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args,
- unsigned NumArgs, const TemplateArgumentListInfo &ArgInfos);
+ TypeSourceInfo *TInfo, StorageClass S, ArrayRef<TemplateArgument> Args,
+ const TemplateArgumentListInfo &ArgInfos);
static VarTemplatePartialSpecializationDecl *CreateDeserialized(ASTContext &C,
unsigned ID);
Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=274475&r1=274474&r2=274475&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Sun Jul 3 16:17:51 2016
@@ -4553,8 +4553,7 @@ Decl *ASTNodeImporter::VisitClassTemplat
D->getTagKind(), DC,
StartLoc, IdLoc,
ClassTemplate,
- TemplateArgs.data(),
- TemplateArgs.size(),
+ TemplateArgs,
/*PrevDecl=*/nullptr);
D2->setSpecializationKind(D->getSpecializationKind());
@@ -4755,7 +4754,7 @@ Decl *ASTNodeImporter::VisitVarTemplateS
// Create a new specialization.
D2 = VarTemplateSpecializationDecl::Create(
Importer.getToContext(), DC, StartLoc, IdLoc, VarTemplate, T, TInfo,
- D->getStorageClass(), TemplateArgs.data(), TemplateArgs.size());
+ D->getStorageClass(), TemplateArgs);
D2->setSpecializationKind(D->getSpecializationKind());
D2->setTemplateArgsInfo(D->getTemplateArgsInfo());
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=274475&r1=274474&r2=274475&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Sun Jul 3 16:17:51 2016
@@ -685,19 +685,18 @@ void TemplateTemplateParmDecl::setDefaul
//===----------------------------------------------------------------------===//
// TemplateArgumentList Implementation
//===----------------------------------------------------------------------===//
-TemplateArgumentList::TemplateArgumentList(const TemplateArgument *Args,
- unsigned NumArgs)
- : Arguments(getTrailingObjects<TemplateArgument>()), NumArguments(NumArgs) {
- std::uninitialized_copy(Args, Args + NumArgs,
+TemplateArgumentList::TemplateArgumentList(ArrayRef<TemplateArgument> Args)
+ : Arguments(getTrailingObjects<TemplateArgument>()),
+ NumArguments(Args.size()) {
+ std::uninitialized_copy(Args.begin(), Args.end(),
getTrailingObjects<TemplateArgument>());
}
TemplateArgumentList *
TemplateArgumentList::CreateCopy(ASTContext &Context,
- const TemplateArgument *Args,
- unsigned NumArgs) {
- void *Mem = Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumArgs));
- return new (Mem) TemplateArgumentList(Args, NumArgs);
+ ArrayRef<TemplateArgument> Args) {
+ void *Mem = Context.Allocate(totalSizeToAlloc<TemplateArgument>(Args.size()));
+ return new (Mem) TemplateArgumentList(Args);
}
FunctionTemplateSpecializationInfo *
@@ -732,15 +731,14 @@ ClassTemplateSpecializationDecl(ASTConte
DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
ClassTemplateSpecializationDecl *PrevDecl)
: CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
SpecializedTemplate->getIdentifier(),
PrevDecl),
SpecializedTemplate(SpecializedTemplate),
ExplicitInfo(nullptr),
- TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args, NumArgs)),
+ TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
SpecializationKind(TSK_Undeclared) {
}
@@ -756,13 +754,12 @@ ClassTemplateSpecializationDecl::Create(
SourceLocation StartLoc,
SourceLocation IdLoc,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
ClassTemplateSpecializationDecl *PrevDecl) {
ClassTemplateSpecializationDecl *Result =
new (Context, DC) ClassTemplateSpecializationDecl(
Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
- SpecializedTemplate, Args, NumArgs, PrevDecl);
+ SpecializedTemplate, Args, PrevDecl);
Result->MayHaveOutOfDateDef = false;
Context.getTypeDeclType(Result, PrevDecl);
@@ -846,15 +843,14 @@ ClassTemplatePartialSpecializationDecl(A
SourceLocation IdLoc,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
const ASTTemplateArgumentListInfo *ArgInfos,
ClassTemplatePartialSpecializationDecl *PrevDecl)
: ClassTemplateSpecializationDecl(Context,
ClassTemplatePartialSpecialization,
TK, DC, StartLoc, IdLoc,
SpecializedTemplate,
- Args, NumArgs, PrevDecl),
+ Args, PrevDecl),
TemplateParams(Params), ArgsAsWritten(ArgInfos),
InstantiatedFromMember(nullptr, false)
{
@@ -867,8 +863,7 @@ Create(ASTContext &Context, TagKind TK,D
SourceLocation StartLoc, SourceLocation IdLoc,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
const TemplateArgumentListInfo &ArgInfos,
QualType CanonInjectedType,
ClassTemplatePartialSpecializationDecl *PrevDecl) {
@@ -878,7 +873,7 @@ Create(ASTContext &Context, TagKind TK,D
ClassTemplatePartialSpecializationDecl *Result = new (Context, DC)
ClassTemplatePartialSpecializationDecl(Context, TK, DC, StartLoc, IdLoc,
Params, SpecializedTemplate, Args,
- NumArgs, ASTArgInfos, PrevDecl);
+ ASTArgInfos, PrevDecl);
Result->setSpecializationKind(TSK_ExplicitSpecialization);
Result->MayHaveOutOfDateDef = false;
@@ -1093,12 +1088,11 @@ VarTemplateDecl::findPartialSpecInstanti
VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(
Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
- TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args,
- unsigned NumArgs)
+ TypeSourceInfo *TInfo, StorageClass S, ArrayRef<TemplateArgument> Args)
: VarDecl(DK, Context, DC, StartLoc, IdLoc,
SpecializedTemplate->getIdentifier(), T, TInfo, S),
SpecializedTemplate(SpecializedTemplate), ExplicitInfo(nullptr),
- TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args, NumArgs)),
+ TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
SpecializationKind(TSK_Undeclared) {}
VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(Kind DK,
@@ -1110,11 +1104,10 @@ VarTemplateSpecializationDecl::VarTempla
VarTemplateSpecializationDecl *VarTemplateSpecializationDecl::Create(
ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
- TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args,
- unsigned NumArgs) {
+ TypeSourceInfo *TInfo, StorageClass S, ArrayRef<TemplateArgument> Args) {
return new (Context, DC) VarTemplateSpecializationDecl(
VarTemplateSpecialization, Context, DC, StartLoc, IdLoc,
- SpecializedTemplate, T, TInfo, S, Args, NumArgs);
+ SpecializedTemplate, T, TInfo, S, Args);
}
VarTemplateSpecializationDecl *
@@ -1157,11 +1150,11 @@ VarTemplatePartialSpecializationDecl::Va
ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, TemplateParameterList *Params,
VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
- StorageClass S, const TemplateArgument *Args, unsigned NumArgs,
+ StorageClass S, ArrayRef<TemplateArgument> Args,
const ASTTemplateArgumentListInfo *ArgInfos)
: VarTemplateSpecializationDecl(VarTemplatePartialSpecialization, Context,
DC, StartLoc, IdLoc, SpecializedTemplate, T,
- TInfo, S, Args, NumArgs),
+ TInfo, S, Args),
TemplateParams(Params), ArgsAsWritten(ArgInfos),
InstantiatedFromMember(nullptr, false) {
// TODO: The template parameters should be in DC by now. Verify.
@@ -1173,7 +1166,7 @@ VarTemplatePartialSpecializationDecl::Cr
ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, TemplateParameterList *Params,
VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
- StorageClass S, const TemplateArgument *Args, unsigned NumArgs,
+ StorageClass S, ArrayRef<TemplateArgument> Args,
const TemplateArgumentListInfo &ArgInfos) {
const ASTTemplateArgumentListInfo *ASTArgInfos
= ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
@@ -1181,7 +1174,7 @@ VarTemplatePartialSpecializationDecl::Cr
VarTemplatePartialSpecializationDecl *Result =
new (Context, DC) VarTemplatePartialSpecializationDecl(
Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
- S, Args, NumArgs, ASTArgInfos);
+ S, Args, ASTArgInfos);
Result->setSpecializationKind(TSK_ExplicitSpecialization);
return Result;
}
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=274475&r1=274474&r2=274475&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sun Jul 3 16:17:51 2016
@@ -2158,7 +2158,7 @@ QualType Sema::CheckTemplateIdType(Templ
return QualType();
TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Converted.data(), Converted.size());
+ Converted);
// Only substitute for the innermost template argument list.
MultiLevelTemplateArgumentList TemplateArgLists;
@@ -2252,8 +2252,7 @@ QualType Sema::CheckTemplateIdType(Templ
ClassTemplate->getTemplatedDecl()->getLocStart(),
ClassTemplate->getLocation(),
ClassTemplate,
- Converted.data(),
- Converted.size(), nullptr);
+ Converted, nullptr);
ClassTemplate->AddSpecialization(Decl, InsertPos);
if (ClassTemplate->isOutOfLine())
Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
@@ -2634,7 +2633,7 @@ DeclResult Sema::ActOnVarTemplateSpecial
VarTemplatePartialSpecializationDecl::Create(
Context, VarTemplate->getDeclContext(), TemplateKWLoc,
TemplateNameLoc, TemplateParams, VarTemplate, DI->getType(), DI, SC,
- Converted.data(), Converted.size(), TemplateArgs);
+ Converted, TemplateArgs);
if (!PrevPartial)
VarTemplate->AddPartialSpecialization(Partial, InsertPos);
@@ -2676,7 +2675,7 @@ DeclResult Sema::ActOnVarTemplateSpecial
// this explicit specialization or friend declaration.
Specialization = VarTemplateSpecializationDecl::Create(
Context, VarTemplate->getDeclContext(), TemplateKWLoc, TemplateNameLoc,
- VarTemplate, DI->getType(), DI, SC, Converted.data(), Converted.size());
+ VarTemplate, DI->getType(), DI, SC, Converted);
Specialization->setTemplateArgsInfo(TemplateArgs);
if (!PrevDecl)
@@ -2784,7 +2783,7 @@ Sema::CheckVarTemplateId(VarTemplateDecl
// that it represents. That is,
VarDecl *InstantiationPattern = Template->getTemplatedDecl();
TemplateArgumentList TemplateArgList(TemplateArgumentList::OnStack,
- Converted.data(), Converted.size());
+ Converted);
TemplateArgumentList *InstantiationArgs = &TemplateArgList;
bool AmbiguousPartialSpec = false;
typedef PartialSpecMatchResult MatchResult;
@@ -3263,8 +3262,7 @@ SubstDefaultTemplateArgument(Sema &SemaR
if (Inst.isInvalid())
return nullptr;
- TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Converted.data(), Converted.size());
+ TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted);
// Only substitute for the innermost template argument list.
MultiLevelTemplateArgumentList TemplateArgLists;
@@ -3316,8 +3314,7 @@ SubstDefaultTemplateArgument(Sema &SemaR
if (Inst.isInvalid())
return ExprError();
- TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Converted.data(), Converted.size());
+ TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted);
// Only substitute for the innermost template argument list.
MultiLevelTemplateArgumentList TemplateArgLists;
@@ -3368,8 +3365,7 @@ SubstDefaultTemplateArgument(Sema &SemaR
if (Inst.isInvalid())
return TemplateName();
- TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Converted.data(), Converted.size());
+ TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted);
// Only substitute for the innermost template argument list.
MultiLevelTemplateArgumentList TemplateArgLists;
@@ -3520,7 +3516,7 @@ bool Sema::CheckTemplateArgument(NamedDe
return true;
TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Converted.data(), Converted.size());
+ Converted);
NTTPType = SubstType(NTTPType,
MultiLevelTemplateArgumentList(TemplateArgs),
NTTP->getLocation(),
@@ -3660,8 +3656,7 @@ bool Sema::CheckTemplateArgument(NamedDe
if (Inst.isInvalid())
return true;
- TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Converted.data(), Converted.size());
+ TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted);
TempParm = cast_or_null<TemplateTemplateParmDecl>(
SubstDecl(TempParm, CurContext,
MultiLevelTemplateArgumentList(TemplateArgs)));
@@ -6391,8 +6386,7 @@ Sema::ActOnClassTemplateSpecialization(S
KWLoc, TemplateNameLoc,
TemplateParams,
ClassTemplate,
- Converted.data(),
- Converted.size(),
+ Converted,
TemplateArgs,
CanonType,
PrevPartial);
@@ -6447,8 +6441,7 @@ Sema::ActOnClassTemplateSpecialization(S
ClassTemplate->getDeclContext(),
KWLoc, TemplateNameLoc,
ClassTemplate,
- Converted.data(),
- Converted.size(),
+ Converted,
PrevDecl);
SetNestedNameSpecifier(Specialization, SS);
if (TemplateParameterLists.size() > 0) {
@@ -7493,8 +7486,7 @@ Sema::ActOnExplicitInstantiation(Scope *
ClassTemplate->getDeclContext(),
KWLoc, TemplateNameLoc,
ClassTemplate,
- Converted.data(),
- Converted.size(),
+ Converted,
PrevDecl);
SetNestedNameSpecifier(Specialization, SS);
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=274475&r1=274474&r2=274475&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Sun Jul 3 16:17:51 2016
@@ -2084,8 +2084,7 @@ ConvertDeducedTemplateArgument(Sema &S,
dyn_cast<NonTypeTemplateParmDecl>(Param)) {
NTTPType = NTTP->getType();
if (NTTPType->isDependentType()) {
- TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Output.data(), Output.size());
+ TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Output);
NTTPType = S.SubstType(NTTPType,
MultiLevelTemplateArgumentList(TemplateArgs),
NTTP->getLocation(),
@@ -2145,8 +2144,7 @@ ConvertDeducedTemplateArgument(Sema &S,
if (Inst.isInvalid())
return true;
- TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
- Output.data(), Output.size());
+ TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Output);
if (!S.SubstDecl(TTP, S.CurContext,
MultiLevelTemplateArgumentList(TemplateArgs)))
return true;
@@ -2194,16 +2192,14 @@ FinishTemplateArgumentDeduction(Sema &S,
Builder)) {
Info.Param = makeTemplateParameter(Param);
// FIXME: These template arguments are temporary. Free them!
- Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder.data(),
- Builder.size()));
+ Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder));
return Sema::TDK_SubstitutionFailure;
}
}
// Form the template argument list from the deduced template arguments.
TemplateArgumentList *DeducedArgumentList
- = TemplateArgumentList::CreateCopy(S.Context, Builder.data(),
- Builder.size());
+ = TemplateArgumentList::CreateCopy(S.Context, Builder);
Info.reset(DeducedArgumentList);
@@ -2335,15 +2331,14 @@ static Sema::TemplateDeductionResult Fin
Info, false, Builder)) {
Info.Param = makeTemplateParameter(Param);
// FIXME: These template arguments are temporary. Free them!
- Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder.data(),
- Builder.size()));
+ Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder));
return Sema::TDK_SubstitutionFailure;
}
}
// Form the template argument list from the deduced template arguments.
TemplateArgumentList *DeducedArgumentList = TemplateArgumentList::CreateCopy(
- S.Context, Builder.data(), Builder.size());
+ S.Context, Builder);
Info.reset(DeducedArgumentList);
@@ -2534,7 +2529,7 @@ Sema::SubstituteExplicitTemplateArgument
// Form the template argument list from the explicitly-specified
// template arguments.
TemplateArgumentList *ExplicitArgumentList
- = TemplateArgumentList::CreateCopy(Context, Builder.data(), Builder.size());
+ = TemplateArgumentList::CreateCopy(Context, Builder);
Info.reset(ExplicitArgumentList);
// Template argument deduction and the final substitution should be
@@ -2817,8 +2812,7 @@ Sema::FinishTemplateArgumentDeduction(Fu
true, Builder)) {
Info.Param = makeTemplateParameter(Param);
// FIXME: These template arguments are temporary. Free them!
- Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(),
- Builder.size()));
+ Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
return TDK_SubstitutionFailure;
}
@@ -2854,8 +2848,7 @@ Sema::FinishTemplateArgumentDeduction(Fu
Builder)) {
Info.Param = makeTemplateParameter(Param);
// FIXME: These template arguments are temporary. Free them!
- Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(),
- Builder.size()));
+ Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
return TDK_SubstitutionFailure;
}
}
@@ -2875,8 +2868,7 @@ Sema::FinishTemplateArgumentDeduction(Fu
if (DefArg.getArgument().isNull()) {
Info.Param = makeTemplateParameter(
const_cast<NamedDecl *>(TemplateParams->getParam(I)));
- Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(),
- Builder.size()));
+ Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
if (PartialOverloading) break;
return HasDefaultArg ? TDK_SubstitutionFailure : TDK_Incomplete;
@@ -2892,8 +2884,7 @@ Sema::FinishTemplateArgumentDeduction(Fu
Info.Param = makeTemplateParameter(
const_cast<NamedDecl *>(TemplateParams->getParam(I)));
// FIXME: These template arguments are temporary. Free them!
- Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(),
- Builder.size()));
+ Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
return TDK_SubstitutionFailure;
}
@@ -2902,7 +2893,7 @@ Sema::FinishTemplateArgumentDeduction(Fu
// Form the template argument list from the deduced template arguments.
TemplateArgumentList *DeducedArgumentList
- = TemplateArgumentList::CreateCopy(Context, Builder.data(), Builder.size());
+ = TemplateArgumentList::CreateCopy(Context, Builder);
Info.reset(DeducedArgumentList);
// Substitute the deduced template arguments into the function template
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=274475&r1=274474&r2=274475&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sun Jul 3 16:17:51 2016
@@ -1606,8 +1606,7 @@ Decl *TemplateDeclInstantiator::VisitFun
ArrayRef<TemplateArgument> Innermost = TemplateArgs.getInnermost();
Function->setFunctionTemplateSpecialization(FunctionTemplate,
TemplateArgumentList::CreateCopy(SemaRef.Context,
- Innermost.begin(),
- Innermost.size()),
+ Innermost),
/*InsertPos=*/nullptr);
} else if (isFriend) {
// Note, we need this connection even if the friend doesn't have a body.
@@ -1898,8 +1897,7 @@ TemplateDeclInstantiator::VisitCXXMethod
ArrayRef<TemplateArgument> Innermost = TemplateArgs.getInnermost();
Method->setFunctionTemplateSpecialization(FunctionTemplate,
TemplateArgumentList::CreateCopy(SemaRef.Context,
- Innermost.begin(),
- Innermost.size()),
+ Innermost),
/*InsertPos=*/nullptr);
} else if (!isFriend) {
// Record that this is an instantiation of a member function.
@@ -2755,8 +2753,7 @@ TemplateDeclInstantiator::VisitClassTemp
D->getLocStart(),
D->getLocation(),
InstClassTemplate,
- Converted.data(),
- Converted.size(),
+ Converted,
PrevDecl);
// Add this partial specialization to the set of class template partial
@@ -2864,8 +2861,7 @@ Decl *TemplateDeclInstantiator::VisitVar
// Build the instantiated declaration
VarTemplateSpecializationDecl *Var = VarTemplateSpecializationDecl::Create(
SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(),
- VarTemplate, DI->getType(), DI, D->getStorageClass(), Converted.data(),
- Converted.size());
+ VarTemplate, DI->getType(), DI, D->getStorageClass(), Converted);
Var->setTemplateArgsInfo(TemplateArgsInfo);
if (InsertPos)
VarTemplate->AddSpecialization(Var, InsertPos);
@@ -3048,8 +3044,7 @@ TemplateDeclInstantiator::InstantiateCla
PartialSpec->getLocation(),
InstParams,
ClassTemplate,
- Converted.data(),
- Converted.size(),
+ Converted,
InstTemplateArgs,
CanonType,
nullptr);
@@ -3177,8 +3172,7 @@ TemplateDeclInstantiator::InstantiateVar
VarTemplatePartialSpecializationDecl::Create(
SemaRef.Context, Owner, PartialSpec->getInnerLocStart(),
PartialSpec->getLocation(), InstParams, VarTemplate, DI->getType(),
- DI, PartialSpec->getStorageClass(), Converted.data(),
- Converted.size(), InstTemplateArgs);
+ DI, PartialSpec->getStorageClass(), Converted, InstTemplateArgs);
// Substitute the nested name specifier, if any.
if (SubstQualifier(PartialSpec, InstPartialSpec))
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=274475&r1=274474&r2=274475&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Sun Jul 3 16:17:51 2016
@@ -826,7 +826,7 @@ void ASTDeclReader::VisitFunctionDecl(Fu
ASTContext &C = Reader.getContext();
TemplateArgumentList *TemplArgList
- = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), TemplArgs.size());
+ = TemplateArgumentList::CreateCopy(C, TemplArgs);
TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc);
for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i)
TemplArgsInfo.addArgument(TemplArgLocs[i]);
@@ -1980,8 +1980,7 @@ ASTDeclReader::VisitClassTemplateSpecial
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
TemplateArgumentList *ArgList
- = TemplateArgumentList::CreateCopy(C, TemplArgs.data(),
- TemplArgs.size());
+ = TemplateArgumentList::CreateCopy(C, TemplArgs);
ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
= new (C) ClassTemplateSpecializationDecl::
SpecializedPartialSpecialization();
@@ -1995,8 +1994,7 @@ ASTDeclReader::VisitClassTemplateSpecial
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
/*Canonicalize*/ true);
- D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs.data(),
- TemplArgs.size());
+ D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
@@ -2099,7 +2097,7 @@ ASTDeclReader::VisitVarTemplateSpecializ
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy(
- C, TemplArgs.data(), TemplArgs.size());
+ C, TemplArgs);
VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS =
new (C)
VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
@@ -2123,8 +2121,7 @@ ASTDeclReader::VisitVarTemplateSpecializ
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
/*Canonicalize*/ true);
- D->TemplateArgs =
- TemplateArgumentList::CreateCopy(C, TemplArgs.data(), TemplArgs.size());
+ D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
@@ -3836,7 +3833,7 @@ void ASTDeclReader::UpdateDecl(Decl *D,
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
auto *TemplArgList = TemplateArgumentList::CreateCopy(
- Reader.getContext(), TemplArgs.data(), TemplArgs.size());
+ Reader.getContext(), TemplArgs);
// FIXME: If we already have a partial specialization set,
// check that it matches.
More information about the cfe-commits
mailing list