r274601 - [AST] Use ArrayRef in more interfaces
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 5 21:19:16 PDT 2016
Author: majnemer
Date: Tue Jul 5 23:19:16 2016
New Revision: 274601
URL: http://llvm.org/viewvc/llvm-project?rev=274601&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/ASTContext.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=274601&r1=274600&r2=274601&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Tue Jul 5 23:19:16 2016
@@ -489,8 +489,8 @@ public:
Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
ASTContext &Context) {
ID.AddInteger(TemplateArgs.size());
- for (unsigned Arg = 0; Arg != TemplateArgs.size(); ++Arg)
- TemplateArgs[Arg].Profile(ID, Context);
+ for (const TemplateArgument &TemplateArg : TemplateArgs)
+ TemplateArg.Profile(ID, Context);
}
};
@@ -1179,9 +1179,8 @@ class NonTypeTemplateParmDecl final
SourceLocation IdLoc, unsigned D, unsigned P,
IdentifierInfo *Id, QualType T,
TypeSourceInfo *TInfo,
- const QualType *ExpandedTypes,
- unsigned NumExpandedTypes,
- TypeSourceInfo **ExpandedTInfos);
+ ArrayRef<QualType> ExpandedTypes,
+ ArrayRef<TypeSourceInfo *> ExpandedTInfos);
friend class ASTDeclReader;
friend TrailingObjects;
@@ -1195,9 +1194,8 @@ public:
static NonTypeTemplateParmDecl *
Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
- QualType T, TypeSourceInfo *TInfo,
- const QualType *ExpandedTypes, unsigned NumExpandedTypes,
- TypeSourceInfo **ExpandedTInfos);
+ QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
+ ArrayRef<TypeSourceInfo *> ExpandedTInfos);
static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C,
unsigned ID);
@@ -1360,8 +1358,7 @@ class TemplateTemplateParmDecl final
TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L,
unsigned D, unsigned P,
IdentifierInfo *Id, TemplateParameterList *Params,
- unsigned NumExpansions,
- TemplateParameterList * const *Expansions);
+ ArrayRef<TemplateParameterList *> Expansions);
public:
static TemplateTemplateParmDecl *Create(const ASTContext &C, DeclContext *DC,
@@ -1768,8 +1765,8 @@ public:
Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
ASTContext &Context) {
ID.AddInteger(TemplateArgs.size());
- for (unsigned Arg = 0; Arg != TemplateArgs.size(); ++Arg)
- TemplateArgs[Arg].Profile(ID, Context);
+ for (const TemplateArgument &TemplateArg : TemplateArgs)
+ TemplateArg.Profile(ID, Context);
}
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -2162,18 +2159,11 @@ private:
// Location of the 'friend' specifier.
SourceLocation FriendLoc;
-
FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- unsigned NParams,
- TemplateParameterList **Params,
- FriendUnion Friend,
- SourceLocation FriendLoc)
- : Decl(Decl::FriendTemplate, DC, Loc),
- NumParams(NParams),
- Params(Params),
- Friend(Friend),
- FriendLoc(FriendLoc)
- {}
+ MutableArrayRef<TemplateParameterList *> Params,
+ FriendUnion Friend, SourceLocation FriendLoc)
+ : Decl(Decl::FriendTemplate, DC, Loc), NumParams(Params.size()),
+ Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
FriendTemplateDecl(EmptyShell Empty)
: Decl(Decl::FriendTemplate, Empty),
@@ -2182,12 +2172,10 @@ private:
{}
public:
- static FriendTemplateDecl *Create(ASTContext &Context,
- DeclContext *DC, SourceLocation Loc,
- unsigned NParams,
- TemplateParameterList **Params,
- FriendUnion Friend,
- SourceLocation FriendLoc);
+ static FriendTemplateDecl *
+ Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc,
+ MutableArrayRef<TemplateParameterList *> Params, FriendUnion Friend,
+ SourceLocation FriendLoc);
static FriendTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -2612,8 +2600,8 @@ public:
ArrayRef<TemplateArgument> TemplateArgs,
ASTContext &Context) {
ID.AddInteger(TemplateArgs.size());
- for (unsigned Arg = 0; Arg != TemplateArgs.size(); ++Arg)
- TemplateArgs[Arg].Profile(ID, Context);
+ for (const TemplateArgument &TemplateArg : TemplateArgs)
+ TemplateArg.Profile(ID, Context);
}
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=274601&r1=274600&r2=274601&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul 5 23:19:16 2016
@@ -633,9 +633,8 @@ ASTContext::getCanonicalTemplateTemplate
NTTP->getPosition(), nullptr,
T,
TInfo,
- ExpandedTypes.data(),
- ExpandedTypes.size(),
- ExpandedTInfos.data());
+ ExpandedTypes,
+ ExpandedTInfos);
} else {
Param = NonTypeTemplateParmDecl::Create(*this, getTranslationUnitDecl(),
SourceLocation(),
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=274601&r1=274600&r2=274601&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Tue Jul 5 23:19:16 2016
@@ -65,32 +65,29 @@ TemplateParameterList *TemplateParameter
unsigned TemplateParameterList::getMinRequiredArguments() const {
unsigned NumRequiredArgs = 0;
- for (iterator P = const_cast<TemplateParameterList *>(this)->begin(),
- PEnd = const_cast<TemplateParameterList *>(this)->end();
- P != PEnd; ++P) {
- if ((*P)->isTemplateParameterPack()) {
- if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P))
+ for (const NamedDecl *P : asArray()) {
+ if (P->isTemplateParameterPack()) {
+ if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P))
if (NTTP->isExpandedParameterPack()) {
NumRequiredArgs += NTTP->getNumExpansionTypes();
continue;
}
-
+
break;
}
-
- if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
+
+ if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(P)) {
if (TTP->hasDefaultArgument())
break;
- } else if (NonTypeTemplateParmDecl *NTTP
- = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
+ } else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
if (NTTP->hasDefaultArgument())
break;
- } else if (cast<TemplateTemplateParmDecl>(*P)->hasDefaultArgument())
+ } else if (cast<TemplateTemplateParmDecl>(P)->hasDefaultArgument())
break;
-
+
++NumRequiredArgs;
}
-
+
return NumRequiredArgs;
}
@@ -111,12 +108,10 @@ unsigned TemplateParameterList::getDepth
static void AdoptTemplateParameterList(TemplateParameterList *Params,
DeclContext *Owner) {
- for (TemplateParameterList::iterator P = Params->begin(),
- PEnd = Params->end();
- P != PEnd; ++P) {
- (*P)->setDeclContext(Owner);
-
- if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(*P))
+ for (NamedDecl *P : *Params) {
+ P->setDeclContext(Owner);
+
+ if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
AdoptTemplateParameterList(TTP->getTemplateParameters(), Owner);
}
}
@@ -157,8 +152,8 @@ RedeclarableTemplateDecl::CommonBase *Re
}
// Update any previous declarations we saw with the common pointer.
- for (unsigned I = 0, N = PrevDecls.size(); I != N; ++I)
- PrevDecls[I]->Common = Common;
+ for (const RedeclarableTemplateDecl *Prev : PrevDecls)
+ Prev->Common = Common;
return Common;
}
@@ -205,44 +200,41 @@ void RedeclarableTemplateDecl::addSpecia
/// \brief Generate the injected template arguments for the given template
/// parameter list, e.g., for the injected-class-name of a class template.
static void GenerateInjectedTemplateArgs(ASTContext &Context,
- TemplateParameterList *Params,
+ TemplateParameterList *Params,
TemplateArgument *Args) {
- for (TemplateParameterList::iterator Param = Params->begin(),
- ParamEnd = Params->end();
- Param != ParamEnd; ++Param) {
+ for (NamedDecl *Param : *Params) {
TemplateArgument Arg;
- if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*Param)) {
+ if (auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
QualType ArgType = Context.getTypeDeclType(TTP);
if (TTP->isParameterPack())
ArgType = Context.getPackExpansionType(ArgType, None);
Arg = TemplateArgument(ArgType);
- } else if (NonTypeTemplateParmDecl *NTTP =
- dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
+ } else if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
Expr *E = new (Context) DeclRefExpr(NTTP, /*enclosing*/ false,
NTTP->getType().getNonLValueExprType(Context),
Expr::getValueKindForType(NTTP->getType()),
NTTP->getLocation());
-
+
if (NTTP->isParameterPack())
E = new (Context) PackExpansionExpr(Context.DependentTy, E,
NTTP->getLocation(), None);
Arg = TemplateArgument(E);
} else {
- TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(*Param);
+ auto *TTP = cast<TemplateTemplateParmDecl>(Param);
if (TTP->isParameterPack())
Arg = TemplateArgument(TemplateName(TTP), Optional<unsigned>());
else
Arg = TemplateArgument(TemplateName(TTP));
}
-
- if ((*Param)->isTemplateParameterPack())
+
+ if (Param->isTemplateParameterPack())
Arg = TemplateArgument::CreatePackCopy(Context, Arg);
*Args++ = Arg;
}
}
-
+
//===----------------------------------------------------------------------===//
// FunctionTemplateDecl Implementation
//===----------------------------------------------------------------------===//
@@ -421,23 +413,17 @@ void ClassTemplateDecl::getPartialSpecia
= getPartialSpecializations();
PS.clear();
PS.reserve(PartialSpecs.size());
- for (llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>::iterator
- P = PartialSpecs.begin(), PEnd = PartialSpecs.end();
- P != PEnd; ++P)
- PS.push_back(P->getMostRecentDecl());
+ for (ClassTemplatePartialSpecializationDecl &P : PartialSpecs)
+ PS.push_back(P.getMostRecentDecl());
}
ClassTemplatePartialSpecializationDecl *
ClassTemplateDecl::findPartialSpecialization(QualType T) {
ASTContext &Context = getASTContext();
- using llvm::FoldingSetVector;
- typedef FoldingSetVector<ClassTemplatePartialSpecializationDecl>::iterator
- partial_spec_iterator;
- for (partial_spec_iterator P = getPartialSpecializations().begin(),
- PEnd = getPartialSpecializations().end();
- P != PEnd; ++P) {
- if (Context.hasSameType(P->getInjectedSpecializationType(), T))
- return P->getMostRecentDecl();
+ for (ClassTemplatePartialSpecializationDecl &P :
+ getPartialSpecializations()) {
+ if (Context.hasSameType(P.getInjectedSpecializationType(), T))
+ return P.getMostRecentDecl();
}
return nullptr;
@@ -447,12 +433,9 @@ ClassTemplatePartialSpecializationDecl *
ClassTemplateDecl::findPartialSpecInstantiatedFromMember(
ClassTemplatePartialSpecializationDecl *D) {
Decl *DCanon = D->getCanonicalDecl();
- for (llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>::iterator
- P = getPartialSpecializations().begin(),
- PEnd = getPartialSpecializations().end();
- P != PEnd; ++P) {
- if (P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
- return P->getMostRecentDecl();
+ for (ClassTemplatePartialSpecializationDecl &P : getPartialSpecializations()) {
+ if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
+ return P.getMostRecentDecl();
}
return nullptr;
@@ -535,20 +518,14 @@ bool TemplateTypeParmDecl::isParameterPa
// NonTypeTemplateParmDecl Method Implementations
//===----------------------------------------------------------------------===//
-NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(DeclContext *DC,
- SourceLocation StartLoc,
- SourceLocation IdLoc,
- unsigned D, unsigned P,
- IdentifierInfo *Id,
- QualType T,
- TypeSourceInfo *TInfo,
- const QualType *ExpandedTypes,
- unsigned NumExpandedTypes,
- TypeSourceInfo **ExpandedTInfos)
- : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
- TemplateParmPosition(D, P), ParameterPack(true),
- ExpandedParameterPack(true), NumExpandedTypes(NumExpandedTypes) {
- if (ExpandedTypes && ExpandedTInfos) {
+NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(
+ DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D,
+ unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
+ ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos)
+ : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
+ TemplateParmPosition(D, P), ParameterPack(true),
+ ExpandedParameterPack(true), NumExpandedTypes(ExpandedTypes.size()) {
+ if (!ExpandedTypes.empty() && !ExpandedTInfos.empty()) {
auto TypesAndInfos =
getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
for (unsigned I = 0; I != NumExpandedTypes; ++I) {
@@ -568,20 +545,16 @@ NonTypeTemplateParmDecl::Create(const AS
T, ParameterPack, TInfo);
}
-NonTypeTemplateParmDecl *
-NonTypeTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC,
- SourceLocation StartLoc, SourceLocation IdLoc,
- unsigned D, unsigned P,
- IdentifierInfo *Id, QualType T,
- TypeSourceInfo *TInfo,
- const QualType *ExpandedTypes,
- unsigned NumExpandedTypes,
- TypeSourceInfo **ExpandedTInfos) {
+NonTypeTemplateParmDecl *NonTypeTemplateParmDecl::Create(
+ const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
+ SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
+ QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
+ ArrayRef<TypeSourceInfo *> ExpandedTInfos) {
return new (C, DC,
additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>>(
- NumExpandedTypes))
+ ExpandedTypes.size()))
NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, TInfo,
- ExpandedTypes, NumExpandedTypes, ExpandedTInfos);
+ ExpandedTypes, ExpandedTInfos);
}
NonTypeTemplateParmDecl *
@@ -594,12 +567,14 @@ NonTypeTemplateParmDecl::CreateDeseriali
NonTypeTemplateParmDecl *
NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID,
unsigned NumExpandedTypes) {
- return new (C, ID,
- additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>>(
- NumExpandedTypes))
- NonTypeTemplateParmDecl(nullptr, SourceLocation(), SourceLocation(), 0, 0,
- nullptr, QualType(), nullptr, nullptr,
- NumExpandedTypes, nullptr);
+ auto *NTTP =
+ new (C, ID, additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>>(
+ NumExpandedTypes))
+ NonTypeTemplateParmDecl(nullptr, SourceLocation(), SourceLocation(),
+ 0, 0, nullptr, QualType(), nullptr, None,
+ None);
+ NTTP->NumExpandedTypes = NumExpandedTypes;
+ return NTTP;
}
SourceRange NonTypeTemplateParmDecl::getSourceRange() const {
@@ -624,12 +599,12 @@ void TemplateTemplateParmDecl::anchor()
TemplateTemplateParmDecl::TemplateTemplateParmDecl(
DeclContext *DC, SourceLocation L, unsigned D, unsigned P,
IdentifierInfo *Id, TemplateParameterList *Params,
- unsigned NumExpansions, TemplateParameterList * const *Expansions)
- : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
- TemplateParmPosition(D, P), ParameterPack(true),
- ExpandedParameterPack(true), NumExpandedParams(NumExpansions) {
- if (Expansions)
- std::uninitialized_copy(Expansions, Expansions + NumExpandedParams,
+ ArrayRef<TemplateParameterList *> Expansions)
+ : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
+ TemplateParmPosition(D, P), ParameterPack(true),
+ ExpandedParameterPack(true), NumExpandedParams(Expansions.size()) {
+ if (!Expansions.empty())
+ std::uninitialized_copy(Expansions.begin(), Expansions.end(),
getTrailingObjects<TemplateParameterList *>());
}
@@ -650,8 +625,7 @@ TemplateTemplateParmDecl::Create(const A
ArrayRef<TemplateParameterList *> Expansions) {
return new (C, DC,
additionalSizeToAlloc<TemplateParameterList *>(Expansions.size()))
- TemplateTemplateParmDecl(DC, L, D, P, Id, Params, Expansions.size(),
- Expansions.data());
+ TemplateTemplateParmDecl(DC, L, D, P, Id, Params, Expansions);
}
TemplateTemplateParmDecl *
@@ -663,10 +637,12 @@ TemplateTemplateParmDecl::CreateDeserial
TemplateTemplateParmDecl *
TemplateTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID,
unsigned NumExpansions) {
- return new (C, ID,
- additionalSizeToAlloc<TemplateParameterList *>(NumExpansions))
- TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0, nullptr,
- nullptr, NumExpansions, nullptr);
+ auto *TTP =
+ new (C, ID, additionalSizeToAlloc<TemplateParameterList *>(NumExpansions))
+ TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0, nullptr,
+ nullptr, None);
+ TTP->NumExpandedParams = NumExpansions;
+ return TTP;
}
SourceLocation TemplateTemplateParmDecl::getDefaultArgumentLoc() const {
@@ -896,15 +872,12 @@ ClassTemplatePartialSpecializationDecl::
void FriendTemplateDecl::anchor() { }
-FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context,
- DeclContext *DC,
- SourceLocation L,
- unsigned NParams,
- TemplateParameterList **Params,
- FriendUnion Friend,
- SourceLocation FLoc) {
- return new (Context, DC) FriendTemplateDecl(DC, L, NParams, Params,
- Friend, FLoc);
+FriendTemplateDecl *
+FriendTemplateDecl::Create(ASTContext &Context, DeclContext *DC,
+ SourceLocation L,
+ MutableArrayRef<TemplateParameterList *> Params,
+ FriendUnion Friend, SourceLocation FLoc) {
+ return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
}
FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,
@@ -1060,23 +1033,17 @@ void VarTemplateDecl::getPartialSpeciali
getPartialSpecializations();
PS.clear();
PS.reserve(PartialSpecs.size());
- for (llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>::iterator
- P = PartialSpecs.begin(),
- PEnd = PartialSpecs.end();
- P != PEnd; ++P)
- PS.push_back(P->getMostRecentDecl());
+ for (VarTemplatePartialSpecializationDecl &P : PartialSpecs)
+ PS.push_back(P.getMostRecentDecl());
}
VarTemplatePartialSpecializationDecl *
VarTemplateDecl::findPartialSpecInstantiatedFromMember(
VarTemplatePartialSpecializationDecl *D) {
Decl *DCanon = D->getCanonicalDecl();
- for (llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>::iterator
- P = getPartialSpecializations().begin(),
- PEnd = getPartialSpecializations().end();
- P != PEnd; ++P) {
- if (P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
- return P->getMostRecentDecl();
+ for (VarTemplatePartialSpecializationDecl &P : getPartialSpecializations()) {
+ if (P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
+ return P.getMostRecentDecl();
}
return nullptr;
@@ -1134,11 +1101,10 @@ VarTemplateDecl *VarTemplateSpecializati
void VarTemplateSpecializationDecl::setTemplateArgsInfo(
const TemplateArgumentListInfo &ArgsInfo) {
- unsigned N = ArgsInfo.size();
TemplateArgsInfo.setLAngleLoc(ArgsInfo.getLAngleLoc());
TemplateArgsInfo.setRAngleLoc(ArgsInfo.getRAngleLoc());
- for (unsigned I = 0; I != N; ++I)
- TemplateArgsInfo.addArgument(ArgsInfo[I]);
+ for (const TemplateArgumentLoc &Loc : ArgsInfo.arguments())
+ TemplateArgsInfo.addArgument(Loc);
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=274601&r1=274600&r2=274601&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jul 5 23:19:16 2016
@@ -12676,10 +12676,9 @@ Decl *Sema::ActOnFriendTypeDecl(Scope *S
// friend a member of an arbitrary specialization of your template).
Decl *D;
- if (unsigned NumTempParamLists = TempParams.size())
+ if (!TempParams.empty())
D = FriendTemplateDecl::Create(Context, CurContext, Loc,
- NumTempParamLists,
- TempParams.data(),
+ TempParams,
TSI,
DS.getFriendSpecLoc());
else
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=274601&r1=274600&r2=274601&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Jul 5 23:19:16 2016
@@ -2155,16 +2155,11 @@ Decl *TemplateDeclInstantiator::VisitNon
NonTypeTemplateParmDecl *Param;
if (IsExpandedParameterPack)
- Param = NonTypeTemplateParmDecl::Create(SemaRef.Context, Owner,
- D->getInnerLocStart(),
- D->getLocation(),
- D->getDepth() - TemplateArgs.getNumLevels(),
- D->getPosition(),
- D->getIdentifier(), T,
- DI,
- ExpandedParameterPackTypes.data(),
- ExpandedParameterPackTypes.size(),
- ExpandedParameterPackTypesAsWritten.data());
+ Param = NonTypeTemplateParmDecl::Create(
+ SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(),
+ D->getDepth() - TemplateArgs.getNumLevels(), D->getPosition(),
+ D->getIdentifier(), T, DI, ExpandedParameterPackTypes,
+ ExpandedParameterPackTypesAsWritten);
else
Param = NonTypeTemplateParmDecl::Create(SemaRef.Context, Owner,
D->getInnerLocStart(),
More information about the cfe-commits
mailing list