summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-07 04:43:07 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-07 04:43:07 +0000
commit6fbeee307e7f3a25d365f74d38f61ff485ac88be (patch)
tree39746f03910268ab8b2809f4d2a1cd2047f0410f /clang
parent00639bc5296194636a37156a90f8f9edb2b0dda8 (diff)
downloadbcm5719-llvm-6fbeee307e7f3a25d365f74d38f61ff485ac88be.tar.gz
bcm5719-llvm-6fbeee307e7f3a25d365f74d38f61ff485ac88be.zip
[AST] Use ArrayRef in more interfaces
ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274732
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/ASTContext.h17
-rw-r--r--clang/include/clang/AST/Expr.h8
-rw-r--r--clang/include/clang/AST/ExprCXX.h12
-rw-r--r--clang/include/clang/AST/Type.h34
-rw-r--r--clang/include/clang/Sema/Sema.h4
-rw-r--r--clang/lib/AST/ASTContext.cpp64
-rw-r--r--clang/lib/AST/ASTDiagnostic.cpp5
-rw-r--r--clang/lib/AST/ASTImporter.cpp3
-rw-r--r--clang/lib/AST/Decl.cpp8
-rw-r--r--clang/lib/AST/DeclTemplate.cpp7
-rw-r--r--clang/lib/AST/NestedNameSpecifier.cpp2
-rw-r--r--clang/lib/AST/StmtPrinter.cpp14
-rw-r--r--clang/lib/AST/Type.cpp53
-rw-r--r--clang/lib/AST/TypePrinter.cpp85
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp6
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp14
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp6
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp12
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp7
-rw-r--r--clang/lib/Serialization/ASTReader.cpp8
-rw-r--r--clang/lib/Tooling/Core/QualTypeNames.cpp4
-rw-r--r--clang/tools/libclang/CIndex.cpp6
23 files changed, 179 insertions, 202 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 2efef57c4f8..1d223f47a9a 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1237,13 +1237,12 @@ public:
TemplateTypeParmDecl *ParmDecl = nullptr) const;
QualType getTemplateSpecializationType(TemplateName T,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
QualType Canon = QualType()) const;
- QualType getCanonicalTemplateSpecializationType(TemplateName T,
- const TemplateArgument *Args,
- unsigned NumArgs) const;
+ QualType
+ getCanonicalTemplateSpecializationType(TemplateName T,
+ ArrayRef<TemplateArgument> Args) const;
QualType getTemplateSpecializationType(TemplateName T,
const TemplateArgumentListInfo &Args,
@@ -1268,11 +1267,9 @@ public:
NestedNameSpecifier *NNS,
const IdentifierInfo *Name,
const TemplateArgumentListInfo &Args) const;
- QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword,
- NestedNameSpecifier *NNS,
- const IdentifierInfo *Name,
- unsigned NumArgs,
- const TemplateArgument *Args) const;
+ QualType getDependentTemplateSpecializationType(
+ ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
+ const IdentifierInfo *Name, ArrayRef<TemplateArgument> Args) const;
QualType getPackExpansionType(QualType Pattern,
Optional<unsigned> NumExpansions);
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index ac77484dfe3..80710e90211 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -1120,6 +1120,10 @@ public:
return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
}
+ ArrayRef<TemplateArgumentLoc> template_arguments() const {
+ return {getTemplateArgs(), getNumTemplateArgs()};
+ }
+
/// \brief Returns true if this expression refers to a function that
/// was resolved from an overloaded set having size greater than 1.
bool hadMultipleCandidates() const {
@@ -2491,6 +2495,10 @@ public:
return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
}
+ ArrayRef<TemplateArgumentLoc> template_arguments() const {
+ return {getTemplateArgs(), getNumTemplateArgs()};
+ }
+
/// \brief Retrieve the member declaration name info.
DeclarationNameInfo getMemberNameInfo() const {
return DeclarationNameInfo(MemberDecl->getDeclName(),
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 8882620b343..86cbfb2cd0b 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2638,6 +2638,10 @@ public:
return getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs;
}
+ ArrayRef<TemplateArgumentLoc> template_arguments() const {
+ return {getTemplateArgs(), getNumTemplateArgs()};
+ }
+
/// \brief Copies the template arguments into the given structure.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
if (hasExplicitTemplateArgs())
@@ -2891,6 +2895,10 @@ public:
return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
}
+ ArrayRef<TemplateArgumentLoc> template_arguments() const {
+ return {getTemplateArgs(), getNumTemplateArgs()};
+ }
+
/// Note: getLocStart() is the start of the whole DependentScopeDeclRefExpr,
/// and differs from getLocation().getStart().
SourceLocation getLocStart() const LLVM_READONLY {
@@ -3306,6 +3314,10 @@ public:
return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
}
+ ArrayRef<TemplateArgumentLoc> template_arguments() const {
+ return {getTemplateArgs(), getNumTemplateArgs()};
+ }
+
SourceLocation getLocStart() const LLVM_READONLY {
if (!isImplicitAccess())
return Base->getLocStart();
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 511bbc47156..7642ad48128 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -4171,16 +4171,15 @@ class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) TemplateSpecializationType
bool TypeAlias : 1;
TemplateSpecializationType(TemplateName T,
- const TemplateArgument *Args,
- unsigned NumArgs, QualType Canon,
+ ArrayRef<TemplateArgument> Args,
+ QualType Canon,
QualType Aliased);
friend class ASTContext; // ASTContext creates these
public:
/// Determine whether any of the given template arguments are dependent.
- static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args,
- unsigned NumArgs,
+ static bool anyDependentTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
bool &InstantiationDependent);
static bool anyDependentTemplateArguments(const TemplateArgumentListInfo &,
@@ -4189,14 +4188,12 @@ public:
/// \brief Print a template argument list, including the '<' and '>'
/// enclosing the template arguments.
static void PrintTemplateArgumentList(raw_ostream &OS,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
const PrintingPolicy &Policy,
bool SkipBrackets = false);
static void PrintTemplateArgumentList(raw_ostream &OS,
- const TemplateArgumentLoc *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgumentLoc> Args,
const PrintingPolicy &Policy);
static void PrintTemplateArgumentList(raw_ostream &OS,
@@ -4253,20 +4250,23 @@ public:
/// \pre \c isArgType(Arg)
const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
+ ArrayRef<TemplateArgument> template_arguments() const {
+ return {getArgs(), NumArgs};
+ }
+
bool isSugared() const {
return !isDependentType() || isCurrentInstantiation() || isTypeAlias();
}
QualType desugar() const { return getCanonicalTypeInternal(); }
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx) {
- Profile(ID, Template, getArgs(), NumArgs, Ctx);
+ Profile(ID, Template, template_arguments(), Ctx);
if (isTypeAlias())
getAliasedType().Profile(ID);
}
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName T,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
const ASTContext &Context);
static bool classof(const Type *T) {
@@ -4570,8 +4570,7 @@ class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) DependentTemplateSpecializationType
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS,
const IdentifierInfo *Name,
- unsigned NumArgs,
- const TemplateArgument *Args,
+ ArrayRef<TemplateArgument> Args,
QualType Canon);
friend class ASTContext; // ASTContext creates these
@@ -4590,6 +4589,10 @@ public:
const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
+ ArrayRef<TemplateArgument> template_arguments() const {
+ return {getArgs(), NumArgs};
+ }
+
typedef const TemplateArgument * iterator;
iterator begin() const { return getArgs(); }
iterator end() const; // inline in TemplateBase.h
@@ -4598,7 +4601,7 @@ public:
QualType desugar() const { return QualType(this, 0); }
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) {
- Profile(ID, Context, getKeyword(), NNS, Name, NumArgs, getArgs());
+ Profile(ID, Context, getKeyword(), NNS, Name, {getArgs(), NumArgs});
}
static void Profile(llvm::FoldingSetNodeID &ID,
@@ -4606,8 +4609,7 @@ public:
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *Qualifier,
const IdentifierInfo *Name,
- unsigned NumArgs,
- const TemplateArgument *Args);
+ ArrayRef<TemplateArgument> Args);
static bool classof(const Type *T) {
return T->getTypeClass() == DependentTemplateSpecialization;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a83862d1e16..950ab493bb7 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6662,6 +6662,10 @@ public:
/// \brief The number of template arguments in TemplateArgs.
unsigned NumTemplateArgs;
+ ArrayRef<TemplateArgument> template_arguments() const {
+ return {TemplateArgs, NumTemplateArgs};
+ }
+
/// \brief The template deduction info object associated with the
/// substitution or checking of explicit or deduced template arguments.
sema::TemplateDeductionInfo *DeductionInfo;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 22831f45d4a..6aad4d1d570 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3393,23 +3393,19 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
QualType Underlying) const {
assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
-
- unsigned NumArgs = Args.size();
SmallVector<TemplateArgument, 4> ArgVec;
- ArgVec.reserve(NumArgs);
- for (unsigned i = 0; i != NumArgs; ++i)
- ArgVec.push_back(Args[i].getArgument());
+ ArgVec.reserve(Args.size());
+ for (const TemplateArgumentLoc &Arg : Args.arguments())
+ ArgVec.push_back(Arg.getArgument());
- return getTemplateSpecializationType(Template, ArgVec.data(), NumArgs,
- Underlying);
+ return getTemplateSpecializationType(Template, ArgVec, Underlying);
}
#ifndef NDEBUG
-static bool hasAnyPackExpansions(const TemplateArgument *Args,
- unsigned NumArgs) {
- for (unsigned I = 0; I != NumArgs; ++I)
- if (Args[I].isPackExpansion())
+static bool hasAnyPackExpansions(ArrayRef<TemplateArgument> Args) {
+ for (const TemplateArgument &Arg : Args)
+ if (Arg.isPackExpansion())
return true;
return true;
@@ -3418,8 +3414,7 @@ static bool hasAnyPackExpansions(const TemplateArgument *Args,
QualType
ASTContext::getTemplateSpecializationType(TemplateName Template,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
QualType Underlying) const {
assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
@@ -3436,32 +3431,29 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
else {
// We can get here with an alias template when the specialization contains
// a pack expansion that does not match up with a parameter pack.
- assert((!IsTypeAlias || hasAnyPackExpansions(Args, NumArgs)) &&
+ assert((!IsTypeAlias || hasAnyPackExpansions(Args)) &&
"Caller must compute aliased type");
IsTypeAlias = false;
- CanonType = getCanonicalTemplateSpecializationType(Template, Args,
- NumArgs);
+ CanonType = getCanonicalTemplateSpecializationType(Template, Args);
}
// Allocate the (non-canonical) template specialization type, but don't
// try to unique it: these types typically have location information that
// we don't unique and don't want to lose.
void *Mem = Allocate(sizeof(TemplateSpecializationType) +
- sizeof(TemplateArgument) * NumArgs +
+ sizeof(TemplateArgument) * Args.size() +
(IsTypeAlias? sizeof(QualType) : 0),
TypeAlignment);
TemplateSpecializationType *Spec
- = new (Mem) TemplateSpecializationType(Template, Args, NumArgs, CanonType,
+ = new (Mem) TemplateSpecializationType(Template, Args, CanonType,
IsTypeAlias ? Underlying : QualType());
Types.push_back(Spec);
return QualType(Spec, 0);
}
-QualType
-ASTContext::getCanonicalTemplateSpecializationType(TemplateName Template,
- const TemplateArgument *Args,
- unsigned NumArgs) const {
+QualType ASTContext::getCanonicalTemplateSpecializationType(
+ TemplateName Template, ArrayRef<TemplateArgument> Args) const {
assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
@@ -3472,15 +3464,16 @@ ASTContext::getCanonicalTemplateSpecializationType(TemplateName Template,
// Build the canonical template specialization type.
TemplateName CanonTemplate = getCanonicalTemplateName(Template);
SmallVector<TemplateArgument, 4> CanonArgs;
+ unsigned NumArgs = Args.size();
CanonArgs.reserve(NumArgs);
- for (unsigned I = 0; I != NumArgs; ++I)
- CanonArgs.push_back(getCanonicalTemplateArgument(Args[I]));
+ for (const TemplateArgument &Arg : Args)
+ CanonArgs.push_back(getCanonicalTemplateArgument(Arg));
// Determine whether this canonical template specialization type already
// exists.
llvm::FoldingSetNodeID ID;
TemplateSpecializationType::Profile(ID, CanonTemplate,
- CanonArgs.data(), NumArgs, *this);
+ CanonArgs, *this);
void *InsertPos = nullptr;
TemplateSpecializationType *Spec
@@ -3492,7 +3485,7 @@ ASTContext::getCanonicalTemplateSpecializationType(TemplateName Template,
sizeof(TemplateArgument) * NumArgs),
TypeAlignment);
Spec = new (Mem) TemplateSpecializationType(CanonTemplate,
- CanonArgs.data(), NumArgs,
+ CanonArgs,
QualType(), QualType());
Types.push_back(Spec);
TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
@@ -3592,9 +3585,7 @@ ASTContext::getDependentTemplateSpecializationType(
SmallVector<TemplateArgument, 16> ArgCopy;
for (unsigned I = 0, E = Args.size(); I != E; ++I)
ArgCopy.push_back(Args[I].getArgument());
- return getDependentTemplateSpecializationType(Keyword, NNS, Name,
- ArgCopy.size(),
- ArgCopy.data());
+ return getDependentTemplateSpecializationType(Keyword, NNS, Name, ArgCopy);
}
QualType
@@ -3602,14 +3593,13 @@ ASTContext::getDependentTemplateSpecializationType(
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS,
const IdentifierInfo *Name,
- unsigned NumArgs,
- const TemplateArgument *Args) const {
+ ArrayRef<TemplateArgument> Args) const {
assert((!NNS || NNS->isDependent()) &&
"nested-name-specifier must be dependent");
llvm::FoldingSetNodeID ID;
DependentTemplateSpecializationType::Profile(ID, *this, Keyword, NNS,
- Name, NumArgs, Args);
+ Name, Args);
void *InsertPos = nullptr;
DependentTemplateSpecializationType *T
@@ -3623,6 +3613,7 @@ ASTContext::getDependentTemplateSpecializationType(
if (Keyword == ETK_None) CanonKeyword = ETK_Typename;
bool AnyNonCanonArgs = false;
+ unsigned NumArgs = Args.size();
SmallVector<TemplateArgument, 16> CanonArgs(NumArgs);
for (unsigned I = 0; I != NumArgs; ++I) {
CanonArgs[I] = getCanonicalTemplateArgument(Args[I]);
@@ -3633,8 +3624,8 @@ ASTContext::getDependentTemplateSpecializationType(
QualType Canon;
if (AnyNonCanonArgs || CanonNNS != NNS || CanonKeyword != Keyword) {
Canon = getDependentTemplateSpecializationType(CanonKeyword, CanonNNS,
- Name, NumArgs,
- CanonArgs.data());
+ Name,
+ CanonArgs);
// Find the insert position again.
DependentTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -3644,7 +3635,7 @@ ASTContext::getDependentTemplateSpecializationType(
sizeof(TemplateArgument) * NumArgs),
TypeAlignment);
T = new (Mem) DependentTemplateSpecializationType(Keyword, NNS,
- Name, NumArgs, Args, Canon);
+ Name, Args, Canon);
Types.push_back(T);
DependentTemplateSpecializationTypes.InsertNode(T, InsertPos);
return QualType(T, 0);
@@ -5756,8 +5747,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
llvm::raw_string_ostream OS(S);
TemplateSpecializationType::PrintTemplateArgumentList(OS,
- TemplateArgs.data(),
- TemplateArgs.size(),
+ TemplateArgs.asArray(),
(*this).getPrintingPolicy());
}
} else {
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index f4961250731..22de8bc0dd0 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -119,7 +119,7 @@ static QualType Desugar(ASTContext &Context, QualType QT, bool &ShouldAKA) {
if (DesugarArgument) {
ShouldAKA = true;
QT = Context.getTemplateSpecializationType(
- TST->getTemplateName(), Args.data(), Args.size(), QT);
+ TST->getTemplateName(), Args, QT);
}
break;
}
@@ -1060,8 +1060,7 @@ class TemplateDiff {
Ty = Context.getTemplateSpecializationType(
TemplateName(CTSD->getSpecializedTemplate()),
- CTSD->getTemplateArgs().data(),
- CTSD->getTemplateArgs().size(),
+ CTSD->getTemplateArgs().asArray(),
Ty.getLocalUnqualifiedType().getCanonicalType());
return Ty->getAs<TemplateSpecializationType>();
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f33532ebe16..f4698ee229b 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1909,8 +1909,7 @@ QualType ASTNodeImporter::VisitTemplateSpecializationType(
return QualType();
}
return Importer.getToContext().getTemplateSpecializationType(ToTemplate,
- ToTemplateArgs.data(),
- ToTemplateArgs.size(),
+ ToTemplateArgs,
ToCanonType);
}
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index b4a5a9b27da..46427abea80 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1428,10 +1428,8 @@ void NamedDecl::printQualifiedName(raw_ostream &OS,
if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
OS << Spec->getName();
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
- TemplateSpecializationType::PrintTemplateArgumentList(OS,
- TemplateArgs.data(),
- TemplateArgs.size(),
- P);
+ TemplateSpecializationType::PrintTemplateArgumentList(
+ OS, TemplateArgs.asArray(), P);
} else if (const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
if (P.SuppressUnwrittenScope &&
(ND->isAnonymousNamespace() || ND->isInline()))
@@ -2444,7 +2442,7 @@ void FunctionDecl::getNameForDiagnostic(
const TemplateArgumentList *TemplateArgs = getTemplateSpecializationArgs();
if (TemplateArgs)
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, TemplateArgs->data(), TemplateArgs->size(), Policy);
+ OS, TemplateArgs->asArray(), Policy);
}
bool FunctionDecl::isVariadic() const {
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index bede057ff42..c4cc79f1a52 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -461,8 +461,7 @@ ClassTemplateDecl::getInjectedClassNameSpecialization() {
GenerateInjectedTemplateArgs(getASTContext(), Params, TemplateArgs.data());
CommonPtr->InjectedClassNameType
= Context.getTemplateSpecializationType(TemplateName(this),
- &TemplateArgs[0],
- TemplateArgs.size());
+ TemplateArgs);
return CommonPtr->InjectedClassNameType;
}
@@ -757,7 +756,7 @@ void ClassTemplateSpecializationDecl::getNameForDiagnostic(
const TemplateArgumentList &TemplateArgs = getTemplateArgs();
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, TemplateArgs.data(), TemplateArgs.size(), Policy);
+ OS, TemplateArgs.asArray(), Policy);
}
ClassTemplateDecl *
@@ -1089,7 +1088,7 @@ void VarTemplateSpecializationDecl::getNameForDiagnostic(
const TemplateArgumentList &TemplateArgs = getTemplateArgs();
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, TemplateArgs.data(), TemplateArgs.size(), Policy);
+ OS, TemplateArgs.asArray(), Policy);
}
VarTemplateDecl *VarTemplateSpecializationDecl::getSpecializedTemplate() const {
diff --git a/clang/lib/AST/NestedNameSpecifier.cpp b/clang/lib/AST/NestedNameSpecifier.cpp
index 2f38db40d9a..82809d7ea7b 100644
--- a/clang/lib/AST/NestedNameSpecifier.cpp
+++ b/clang/lib/AST/NestedNameSpecifier.cpp
@@ -315,7 +315,7 @@ NestedNameSpecifier::print(raw_ostream &OS,
// Print the template argument list.
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, SpecType->getArgs(), SpecType->getNumArgs(), InnerPolicy);
+ OS, SpecType->template_arguments(), InnerPolicy);
} else {
// Print the type normally
QualType(T, 0).print(OS, InnerPolicy);
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index b5c24b93323..cb6298b160e 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1187,7 +1187,7 @@ void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
OS << Node->getNameInfo();
if (Node->hasExplicitTemplateArgs())
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
+ OS, Node->template_arguments(), Policy);
}
void StmtPrinter::VisitDependentScopeDeclRefExpr(
@@ -1199,7 +1199,7 @@ void StmtPrinter::VisitDependentScopeDeclRefExpr(
OS << Node->getNameInfo();
if (Node->hasExplicitTemplateArgs())
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
+ OS, Node->template_arguments(), Policy);
}
void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
@@ -1210,7 +1210,7 @@ void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
OS << Node->getNameInfo();
if (Node->hasExplicitTemplateArgs())
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
+ OS, Node->template_arguments(), Policy);
}
void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
@@ -1537,7 +1537,7 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
OS << Node->getMemberNameInfo();
if (Node->hasExplicitTemplateArgs())
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
+ OS, Node->template_arguments(), Policy);
}
void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
PrintExpr(Node->getBase());
@@ -1917,7 +1917,7 @@ void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
if (Args->size() != 1) {
OS << "operator\"\"" << Node->getUDSuffix()->getName();
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Args->data(), Args->size(), Policy);
+ OS, Args->asArray(), Policy);
OS << "()";
return;
}
@@ -2242,7 +2242,7 @@ void StmtPrinter::VisitCXXDependentScopeMemberExpr(
OS << Node->getMemberNameInfo();
if (Node->hasExplicitTemplateArgs())
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
+ OS, Node->template_arguments(), Policy);
}
void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
@@ -2257,7 +2257,7 @@ void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
OS << Node->getMemberNameInfo();
if (Node->hasExplicitTemplateArgs())
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
+ OS, Node->template_arguments(), Policy);
}
static const char *getTypeTraitName(TypeTrait TT) {
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index a0a751e7602..99b024701aa 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2460,19 +2460,20 @@ StringRef TypeWithKeyword::getKeywordName(ElaboratedTypeKeyword Keyword) {
DependentTemplateSpecializationType::DependentTemplateSpecializationType(
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS, const IdentifierInfo *Name,
- unsigned NumArgs, const TemplateArgument *Args,
+ ArrayRef<TemplateArgument> Args,
QualType Canon)
: TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon, true, true,
/*VariablyModified=*/false,
NNS && NNS->containsUnexpandedParameterPack()),
- NNS(NNS), Name(Name), NumArgs(NumArgs) {
+ NNS(NNS), Name(Name), NumArgs(Args.size()) {
assert((!NNS || NNS->isDependent()) &&
"DependentTemplateSpecializatonType requires dependent qualifier");
- for (unsigned I = 0; I != NumArgs; ++I) {
- if (Args[I].containsUnexpandedParameterPack())
+ TemplateArgument *ArgBuffer = getArgBuffer();
+ for (const TemplateArgument &Arg : Args) {
+ if (Arg.containsUnexpandedParameterPack())
setContainsUnexpandedParameterPack();
- new (&getArgBuffer()[I]) TemplateArgument(Args[I]);
+ new (ArgBuffer++) TemplateArgument(Arg);
}
}
@@ -2482,13 +2483,12 @@ DependentTemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *Qualifier,
const IdentifierInfo *Name,
- unsigned NumArgs,
- const TemplateArgument *Args) {
+ ArrayRef<TemplateArgument> Args) {
ID.AddInteger(Keyword);
ID.AddPointer(Qualifier);
ID.AddPointer(Name);
- for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
- Args[Idx].Profile(ID, Context);
+ for (const TemplateArgument &Arg : Args)
+ Arg.Profile(ID, Context);
}
bool Type::isElaboratedTypeSpecifier() const {
@@ -3100,20 +3100,20 @@ void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID,
bool TemplateSpecializationType::
anyDependentTemplateArguments(const TemplateArgumentListInfo &Args,
bool &InstantiationDependent) {
- return anyDependentTemplateArguments(Args.getArgumentArray(), Args.size(),
+ return anyDependentTemplateArguments(Args.arguments(),
InstantiationDependent);
}
bool TemplateSpecializationType::
-anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned N,
+anyDependentTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
bool &InstantiationDependent) {
- for (unsigned i = 0; i != N; ++i) {
- if (Args[i].getArgument().isDependent()) {
+ for (const TemplateArgumentLoc &ArgLoc : Args) {
+ if (ArgLoc.getArgument().isDependent()) {
InstantiationDependent = true;
return true;
}
-
- if (Args[i].getArgument().isInstantiationDependent())
+
+ if (ArgLoc.getArgument().isInstantiationDependent())
InstantiationDependent = true;
}
return false;
@@ -3121,7 +3121,7 @@ anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned N,
TemplateSpecializationType::
TemplateSpecializationType(TemplateName T,
- const TemplateArgument *Args, unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
QualType Canon, QualType AliasedType)
: Type(TemplateSpecialization,
Canon.isNull()? QualType(this, 0) : Canon,
@@ -3129,7 +3129,7 @@ TemplateSpecializationType(TemplateName T,
Canon.isNull()? true : Canon->isInstantiationDependentType(),
false,
T.containsUnexpandedParameterPack()),
- Template(T), NumArgs(NumArgs), TypeAlias(!AliasedType.isNull()) {
+ Template(T), NumArgs(Args.size()), TypeAlias(!AliasedType.isNull()) {
assert(!T.getAsDependentTemplateName() &&
"Use DependentTemplateSpecializationType for dependent template-name");
assert((T.getKind() == TemplateName::Template ||
@@ -3139,7 +3139,7 @@ TemplateSpecializationType(TemplateName T,
TemplateArgument *TemplateArgs
= reinterpret_cast<TemplateArgument *>(this + 1);
- for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
+ for (const TemplateArgument &Arg : Args) {
// Update instantiation-dependent and variably-modified bits.
// If the canonical type exists and is non-dependent, the template
// specialization type can be non-dependent even if one of the type
@@ -3148,14 +3148,14 @@ TemplateSpecializationType(TemplateName T,
// U<T> is always non-dependent, irrespective of the type T.
// However, U<Ts> contains an unexpanded parameter pack, even though
// its expansion (and thus its desugared type) doesn't.
- if (Args[Arg].isInstantiationDependent())
+ if (Arg.isInstantiationDependent())
setInstantiationDependent();
- if (Args[Arg].getKind() == TemplateArgument::Type &&
- Args[Arg].getAsType()->isVariablyModifiedType())
+ if (Arg.getKind() == TemplateArgument::Type &&
+ Arg.getAsType()->isVariablyModifiedType())
setVariablyModified();
- if (Args[Arg].containsUnexpandedParameterPack())
+ if (Arg.containsUnexpandedParameterPack())
setContainsUnexpandedParameterPack();
- new (&TemplateArgs[Arg]) TemplateArgument(Args[Arg]);
+ new (TemplateArgs++) TemplateArgument(Arg);
}
// Store the aliased type if this is a type alias template specialization.
@@ -3168,12 +3168,11 @@ TemplateSpecializationType(TemplateName T,
void
TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
TemplateName T,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef<TemplateArgument> Args,
const ASTContext &Context) {
T.Profile(ID);
- for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
- Args[Idx].Profile(ID, Context);
+ for (const TemplateArgument &Arg : Args)
+ Arg.Profile(ID, Context);
}
QualType
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 030afd9cfc5..065a2db0914 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -923,10 +923,8 @@ void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
OS << Spec->getIdentifier()->getName();
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
- TemplateSpecializationType::PrintTemplateArgumentList(OS,
- TemplateArgs.data(),
- TemplateArgs.size(),
- Policy);
+ TemplateSpecializationType::PrintTemplateArgumentList(
+ OS, TemplateArgs.asArray(), Policy);
OS << "::";
} else if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) {
if (TypedefNameDecl *Typedef = Tag->getTypedefNameForAnonDecl())
@@ -1003,22 +1001,17 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) {
// arguments.
if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(D)) {
- const TemplateArgument *Args;
- unsigned NumArgs;
+ ArrayRef<TemplateArgument> Args;
if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) {
const TemplateSpecializationType *TST =
cast<TemplateSpecializationType>(TAW->getType());
- Args = TST->getArgs();
- NumArgs = TST->getNumArgs();
+ Args = TST->template_arguments();
} else {
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
- Args = TemplateArgs.data();
- NumArgs = TemplateArgs.size();
+ Args = TemplateArgs.asArray();
}
IncludeStrongLifetimeRAII Strong(Policy);
- TemplateSpecializationType::PrintTemplateArgumentList(OS,
- Args, NumArgs,
- Policy);
+ TemplateSpecializationType::PrintTemplateArgumentList(OS, Args, Policy);
}
spaceBeforePlaceHolder(OS);
@@ -1076,11 +1069,9 @@ void TypePrinter::printTemplateSpecializationBefore(
raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
T->getTemplateName().print(OS, Policy);
-
- TemplateSpecializationType::PrintTemplateArgumentList(OS,
- T->getArgs(),
- T->getNumArgs(),
- Policy);
+
+ TemplateSpecializationType::PrintTemplateArgumentList(
+ OS, T->template_arguments(), Policy);
spaceBeforePlaceHolder(OS);
}
void TypePrinter::printTemplateSpecializationAfter(
@@ -1157,8 +1148,7 @@ void TypePrinter::printDependentTemplateSpecializationBefore(
T->getQualifier()->print(OS, Policy);
OS << T->getIdentifier()->getName();
TemplateSpecializationType::PrintTemplateArgumentList(OS,
- T->getArgs(),
- T->getNumArgs(),
+ T->template_arguments(),
Policy);
spaceBeforePlaceHolder(OS);
}
@@ -1445,50 +1435,46 @@ void TemplateSpecializationType::
const TemplateArgumentListInfo &Args,
const PrintingPolicy &Policy) {
return PrintTemplateArgumentList(OS,
- Args.getArgumentArray(),
- Args.size(),
+ Args.arguments(),
Policy);
}
-void
-TemplateSpecializationType::PrintTemplateArgumentList(
- raw_ostream &OS,
- const TemplateArgument *Args,
- unsigned NumArgs,
- const PrintingPolicy &Policy,
- bool SkipBrackets) {
+void TemplateSpecializationType::PrintTemplateArgumentList(
+ raw_ostream &OS, ArrayRef<TemplateArgument> Args,
+ const PrintingPolicy &Policy, bool SkipBrackets) {
const char *Comma = Policy.MSVCFormatting ? "," : ", ";
if (!SkipBrackets)
OS << '<';
-
+
bool needSpace = false;
- for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
+ bool FirstArg = true;
+ for (const TemplateArgument &Arg : Args) {
// Print the argument into a string.
SmallString<128> Buf;
llvm::raw_svector_ostream ArgOS(Buf);
- if (Args[Arg].getKind() == TemplateArgument::Pack) {
- if (Args[Arg].pack_size() && Arg > 0)
+ if (Arg.getKind() == TemplateArgument::Pack) {
+ if (Arg.pack_size() && !FirstArg)
OS << Comma;
PrintTemplateArgumentList(ArgOS,
- Args[Arg].pack_begin(),
- Args[Arg].pack_size(),
+ Arg.getPackAsArray(),
Policy, true);
} else {
- if (Arg > 0)
+ if (!FirstArg)
OS << Comma;
- Args[Arg].print(Policy, ArgOS);
+ Arg.print(Policy, ArgOS);
}
StringRef ArgString = ArgOS.str();
// If this is the first argument and its string representation
// begins with the global scope specifier ('::foo'), add a space
// to avoid printing the diagraph '<:'.
- if (!Arg && !ArgString.empty() && ArgString[0] == ':')
+ if (FirstArg && !ArgString.empty() && ArgString[0] == ':')
OS << ' ';
OS << ArgString;
needSpace = (!ArgString.empty() && ArgString.back() == '>');
+ FirstArg = false;
}
// If the last character of our string is '>', add another space to
@@ -1504,40 +1490,41 @@ TemplateSpecializationType::PrintTemplateArgumentList(
// Sadly, repeat all that with TemplateArgLoc.
void TemplateSpecializationType::
PrintTemplateArgumentList(raw_ostream &OS,
- const TemplateArgumentLoc *Args, unsigned NumArgs,
+ ArrayRef<TemplateArgumentLoc> Args,
const PrintingPolicy &Policy) {
OS << '<';
const char *Comma = Policy.MSVCFormatting ? "," : ", ";
bool needSpace = false;
- for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
- if (Arg > 0)
+ bool FirstArg = true;
+ for (const TemplateArgumentLoc &Arg : Args) {
+ if (!FirstArg)
OS << Comma;
-
+
// Print the argument into a string.
SmallString<128> Buf;
llvm::raw_svector_ostream ArgOS(Buf);
- if (Args[Arg].getArgument().getKind() == TemplateArgument::Pack) {
+ if (Arg.getArgument().getKind() == TemplateArgument::Pack) {
PrintTemplateArgumentList(ArgOS,
- Args[Arg].getArgument().pack_begin(),
- Args[Arg].getArgument().pack_size(),
+ Arg.getArgument().getPackAsArray(),
Policy, true);
} else {
- Args[Arg].getArgument().print(Policy, ArgOS);
+ Arg.getArgument().print(Policy, ArgOS);
}
StringRef ArgString = ArgOS.str();
-
+
// If this is the first argument and its string representation
// begins with the global scope specifier ('::foo'), add a space
// to avoid printing the diagraph '<:'.
- if (!Arg && !ArgString.empty() && ArgString[0] == ':')
+ if (FirstArg && !ArgString.empty() && ArgString[0] == ':')
OS << ' ';
OS << ArgString;
needSpace = (!ArgString.empty() && ArgString.back() == '>');
+ FirstArg = false;
}
-
+
// If the last character of our string is '>', add another space to
// keep the two '>''s separate tokens. We don't *have* to do this in
// C++0x, but it's still good hygiene.
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5e829cc1229..c3e1c5bf2bf 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -209,9 +209,7 @@ StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) {
// Add any template specialization args.
if (Info) {
const TemplateArgumentList *TArgs = Info->TemplateArguments;
- const TemplateArgument *Args = TArgs->data();
- unsigned NumArgs = TArgs->size();
- TemplateSpecializationType::PrintTemplateArgumentList(OS, Args, NumArgs,
+ TemplateSpecializationType::PrintTemplateArgumentList(OS, TArgs->asArray(),
Policy);
}
@@ -845,7 +843,7 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,
/*qualified*/ false);
TemplateSpecializationType::PrintTemplateArgumentList(
- OS, Ty->getArgs(), Ty->getNumArgs(),
+ OS, Ty->template_arguments(),
CGM.getContext().getPrintingPolicy());
TypeAliasDecl *AliasDecl = cast<TypeAliasTemplateDecl>(
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7797ff1efc4..dd7a68cefb5 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8307,7 +8307,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
if (isFunctionTemplateSpecialization && isFriend &&
(NewFD->getType()->isDependentType() || DC->isDependentContext() ||
TemplateSpecializationType::anyDependentTemplateArguments(
- TemplateArgs.getArgumentArray(), TemplateArgs.size(),
+ TemplateArgs,
InstantiationDependent))) {
assert(HasExplicitTemplateArgs &&
"friend function specialization without template args");
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 0b516b833a7..862447b7d5c 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2189,8 +2189,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
// template<typename T, typename U = T> struct A;
TemplateName CanonName = Context.getCanonicalTemplateName(Name);
CanonType = Context.getTemplateSpecializationType(CanonName,
- Converted.data(),
- Converted.size());
+ Converted);
// FIXME: CanonType is not actually the canonical type, and unfortunately
// it is a TemplateSpecializationType that we will never use again.
@@ -2576,7 +2575,7 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
bool InstantiationDependent;
if (!Name.isDependent() &&
!TemplateSpecializationType::anyDependentTemplateArguments(
- TemplateArgs.getArgumentArray(), TemplateArgs.size(),
+ TemplateArgs.arguments(),
InstantiationDependent)) {
Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
<< VarTemplate->getDeclName();
@@ -6319,9 +6318,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
bool InstantiationDependent;
if (!Name.isDependent() &&
!TemplateSpecializationType::anyDependentTemplateArguments(
- TemplateArgs.getArgumentArray(),
- TemplateArgs.size(),
- InstantiationDependent)) {
+ TemplateArgs.arguments(), InstantiationDependent)) {
Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
<< ClassTemplate->getDeclName();
isPartialSpecialization = false;
@@ -6354,8 +6351,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// arguments of the class template partial specialization.
TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name);
CanonType = Context.getTemplateSpecializationType(CanonTemplate,
- Converted.data(),
- Converted.size());
+ Converted);
if (Context.hasSameType(CanonType,
ClassTemplate->getInjectedClassNameSpecialization())) {
@@ -6459,7 +6455,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
"Only possible with -fms-extensions!");
TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name);
CanonType = Context.getTemplateSpecializationType(
- CanonTemplate, Converted.data(), Converted.size());
+ CanonTemplate, Converted);
} else {
CanonType = Context.getTypeDeclType(Specialization);
}
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index e67211b7057..5740bc712e8 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4596,11 +4596,9 @@ Sema::getMoreSpecializedPartialSpecialization(
TemplateName Name(PS1->getSpecializedTemplate());
TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name);
QualType PT1 = Context.getTemplateSpecializationType(
- CanonTemplate, PS1->getTemplateArgs().data(),
- PS1->getTemplateArgs().size());
+ CanonTemplate, PS1->getTemplateArgs().asArray());
QualType PT2 = Context.getTemplateSpecializationType(
- CanonTemplate, PS2->getTemplateArgs().data(),
- PS2->getTemplateArgs().size());
+ CanonTemplate, PS2->getTemplateArgs().asArray());
// Determine whether PS1 is at least as specialized as PS2
Deduced.resize(PS2->getTemplateParameters()->size());
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index ba12fcf540b..4f1879c2ded 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -447,10 +447,8 @@ void Sema::PrintInstantiationStack() {
SmallVector<char, 128> TemplateArgsStr;
llvm::raw_svector_ostream OS(TemplateArgsStr);
Template->printName(OS);
- TemplateSpecializationType::PrintTemplateArgumentList(OS,
- Active->TemplateArgs,
- Active->NumTemplateArgs,
- getPrintingPolicy());
+ TemplateSpecializationType::PrintTemplateArgumentList(
+ OS, Active->template_arguments(), getPrintingPolicy());
Diags.Report(Active->PointOfInstantiation,
diag::note_default_arg_instantiation_here)
<< OS.str()
@@ -501,10 +499,8 @@ void Sema::PrintInstantiationStack() {
SmallVector<char, 128> TemplateArgsStr;
llvm::raw_svector_ostream OS(TemplateArgsStr);
FD->printName(OS);
- TemplateSpecializationType::PrintTemplateArgumentList(OS,
- Active->TemplateArgs,
- Active->NumTemplateArgs,
- getPrintingPolicy());
+ TemplateSpecializationType::PrintTemplateArgumentList(
+ OS, Active->template_arguments(), getPrintingPolicy());
Diags.Report(Active->PointOfInstantiation,
diag::note_default_function_arg_instantiation_here)
<< OS.str()
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index cdcdaac5d1d..4d75f80d1f7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2763,7 +2763,7 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
// Build the canonical type that describes the converted template
// arguments of the class template explicit specialization.
QualType CanonType = SemaRef.Context.getTemplateSpecializationType(
- TemplateName(InstClassTemplate), Converted.data(), Converted.size(),
+ TemplateName(InstClassTemplate), Converted,
SemaRef.Context.getRecordType(InstD));
// Build the fully-sugared type for this class template
@@ -2989,8 +2989,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization(
// arguments of the class template partial specialization.
QualType CanonType
= SemaRef.Context.getTemplateSpecializationType(TemplateName(ClassTemplate),
- Converted.data(),
- Converted.size());
+ Converted);
// Build the fully-sugared type for this class template
// specialization as the user wrote in the specialization
@@ -3111,7 +3110,7 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization(
// Build the canonical type that describes the converted template
// arguments of the variable template partial specialization.
QualType CanonType = SemaRef.Context.getTemplateSpecializationType(
- TemplateName(VarTemplate), Converted.data(), Converted.size());
+ TemplateName(VarTemplate), Converted);
// Build the fully-sugared type for this variable template
// specialization as the user wrote in the specialization
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 27ef02f5b06..80fef7d39e3 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5624,7 +5624,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
while (NumArgs--)
Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
return Context.getDependentTemplateSpecializationType(Keyword, NNS, Name,
- Args.size(), Args.data());
+ Args);
}
case TYPE_DEPENDENT_SIZED_ARRAY: {
@@ -5653,11 +5653,9 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
QualType Underlying = readType(*Loc.F, Record, Idx);
QualType T;
if (Underlying.isNull())
- T = Context.getCanonicalTemplateSpecializationType(Name, Args.data(),
- Args.size());
+ T = Context.getCanonicalTemplateSpecializationType(Name, Args);
else
- T = Context.getTemplateSpecializationType(Name, Args.data(),
- Args.size(), Underlying);
+ T = Context.getTemplateSpecializationType(Name, Args, Underlying);
const_cast<Type*>(T.getTypePtr())->setDependent(IsDependent);
return T;
}
diff --git a/clang/lib/Tooling/Core/QualTypeNames.cpp b/clang/lib/Tooling/Core/QualTypeNames.cpp
index eeb155839d1..619dae1ee10 100644
--- a/clang/lib/Tooling/Core/QualTypeNames.cpp
+++ b/clang/lib/Tooling/Core/QualTypeNames.cpp
@@ -155,7 +155,7 @@ static const Type *getFullyQualifiedTemplateType(const ASTContext &Ctx,
// allocate new type in the AST.
if (MightHaveChanged) {
QualType QT = Ctx.getTemplateSpecializationType(
- TST->getTemplateName(), FQArgs.data(), FQArgs.size(),
+ TST->getTemplateName(), FQArgs,
TST->getCanonicalTypeInternal());
// getTemplateSpecializationType returns a fully qualified
// version of the specialization itself, so no need to qualify
@@ -187,7 +187,7 @@ static const Type *getFullyQualifiedTemplateType(const ASTContext &Ctx,
if (MightHaveChanged) {
TemplateName TN(TSTDecl->getSpecializedTemplate());
QualType QT = Ctx.getTemplateSpecializationType(
- TN, FQArgs.data(), FQArgs.size(),
+ TN, FQArgs,
TSTRecord->getCanonicalTypeInternal());
// getTemplateSpecializationType returns a fully qualified
// version of the specialization itself, so no need to qualify
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index c84a97e60d8..255d5131869 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -4458,10 +4458,8 @@ CXString clang_getCursorDisplayName(CXCursor C) {
SmallString<128> Str;
llvm::raw_svector_ostream OS(Str);
OS << *ClassSpec;
- TemplateSpecializationType::PrintTemplateArgumentList(OS,
- ClassSpec->getTemplateArgs().data(),
- ClassSpec->getTemplateArgs().size(),
- Policy);
+ TemplateSpecializationType::PrintTemplateArgumentList(
+ OS, ClassSpec->getTemplateArgs().asArray(), Policy);
return cxstring::createDup(OS.str());
}
OpenPOWER on IntegriCloud