3 changes: 1 addition & 2 deletions clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1909,8 +1909,7 @@ QualType ASTNodeImporter::VisitTemplateSpecializationType(
return QualType();
}
return Importer.getToContext().getTemplateSpecializationType(ToTemplate,
ToTemplateArgs.data(),
ToTemplateArgs.size(),
ToTemplateArgs,
ToCanonType);
}

Expand Down
8 changes: 3 additions & 5 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -757,7 +756,7 @@ void ClassTemplateSpecializationDecl::getNameForDiagnostic(

const TemplateArgumentList &TemplateArgs = getTemplateArgs();
TemplateSpecializationType::PrintTemplateArgumentList(
OS, TemplateArgs.data(), TemplateArgs.size(), Policy);
OS, TemplateArgs.asArray(), Policy);
}

ClassTemplateDecl *
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/NestedNameSpecifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/AST/StmtPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
53 changes: 26 additions & 27 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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 {
Expand Down Expand Up @@ -3100,36 +3100,36 @@ 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;
}

TemplateSpecializationType::
TemplateSpecializationType(TemplateName T,
const TemplateArgument *Args, unsigned NumArgs,
ArrayRef<TemplateArgument> Args,
QualType Canon, QualType AliasedType)
: Type(TemplateSpecialization,
Canon.isNull()? QualType(this, 0) : Canon,
Canon.isNull()? true : Canon->isDependentType(),
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 ||
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down
85 changes: 36 additions & 49 deletions clang/lib/AST/TypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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>(
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 5 additions & 9 deletions clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Sema/SemaTemplateDeduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
12 changes: 4 additions & 8 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Tooling/Core/QualTypeNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions clang/tools/libclang/CIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down