}
};
+/// \brief A template argument list.
+///
+/// FIXME: In the future, this class will be extended to support
+/// variadic templates and member templates, which will make some of
+/// the function names below make more sense.
+class TemplateArgumentList {
+ /// \brief The template argument list.
+ ///
+ /// The integer value will be non-zero to indicate that this
+ /// template argument list does not own the pointer.
+ llvm::PointerIntPair<TemplateArgument *, 1> Arguments;
+
+ /// \brief The number of template arguments in this template
+ /// argument list.
+ unsigned NumArguments;
+
+
+public:
+ TemplateArgumentList(ASTContext &Context,
+ TemplateArgument *TemplateArgs,
+ unsigned NumTemplateArgs,
+ bool CopyArgs);
+
+ ~TemplateArgumentList();
+
+ /// \brief Retrieve the template argument at a given index.
+ const TemplateArgument &get(unsigned Idx) const {
+ assert(Idx < NumArguments && "Invalid template argument index");
+ return getFlatArgumentList()[Idx];
+ }
+
+ /// \brief Retrieve the template argument at a given index.
+ TemplateArgument &get(unsigned Idx) {
+ assert(Idx < NumArguments && "Invalid template argument index");
+ return getFlatArgumentList()[Idx];
+ }
+
+ /// \brief Retrieve the template argument at a given index.
+ TemplateArgument &operator[](unsigned Idx) { return get(Idx); }
+ const TemplateArgument &operator[](unsigned Idx) const { return get(Idx); }
+
+ /// \brief Retrieve the number of template arguments in this
+ /// template argument list.
+ unsigned size() const { return NumArguments; }
+
+ /// \brief Retrieve the number of template arguments in the
+ /// flattened template argument list.
+ unsigned flat_size() const { return NumArguments; }
+
+ /// \brief Retrieve the flattened template argument list.
+ TemplateArgument *getFlatArgumentList() {
+ return Arguments.getPointer();
+ }
+ const TemplateArgument *getFlatArgumentList() const {
+ return Arguments.getPointer();
+ }
+};
+
// \brief Describes the kind of template specialization that a
// particular template specialization declaration represents.
enum TemplateSpecializationKind {
/// \brief The template that this specialization specializes
ClassTemplateDecl *SpecializedTemplate;
- /// \brief The number of template arguments. The actual arguments
- /// are allocated after the ClassTemplateSpecializationDecl object.
- unsigned NumTemplateArgs : 16;
+ /// \brief The template arguments used to describe this specialization.
+ TemplateArgumentList TemplateArgs;
/// \brief The kind of specialization this declaration refers to.
/// Really a value of type TemplateSpecializationKind.
unsigned SpecializationKind : 2;
- ClassTemplateSpecializationDecl(DeclContext *DC, SourceLocation L,
+ ClassTemplateSpecializationDecl(ASTContext &Context,
+ DeclContext *DC, SourceLocation L,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgument *TemplateArgs,
+ TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs);
public:
return SpecializedTemplate;
}
- typedef const TemplateArgument * template_arg_iterator;
- template_arg_iterator template_arg_begin() const {
- return reinterpret_cast<template_arg_iterator>(this + 1);
- }
-
- template_arg_iterator template_arg_end() const {
- return template_arg_begin() + NumTemplateArgs;
+ const TemplateArgumentList &getTemplateArgs() const {
+ return TemplateArgs;
}
- const TemplateArgument *getTemplateArgs() const {
- return template_arg_begin();
- }
-
- unsigned getNumTemplateArgs() const { return NumTemplateArgs; }
-
/// \brief Determine the kind of specialization that this
/// declaration represents.
TemplateSpecializationKind getSpecializationKind() const {
}
void Profile(llvm::FoldingSetNodeID &ID) const {
- Profile(ID, template_arg_begin(), getNumTemplateArgs());
+ Profile(ID, TemplateArgs.getFlatArgumentList(), TemplateArgs.flat_size());
}
/// \brief Sets the type of this specialization as it was written by
StartLoc = E->getSourceRange().getBegin();
}
+//===----------------------------------------------------------------------===//
+// TemplateArgumentList Implementation
+//===----------------------------------------------------------------------===//
+TemplateArgumentList::TemplateArgumentList(ASTContext &Context,
+ TemplateArgument *TemplateArgs,
+ unsigned NumTemplateArgs,
+ bool CopyArgs)
+ : NumArguments(NumTemplateArgs) {
+ if (!CopyArgs) {
+ Arguments.setPointer(TemplateArgs);
+ Arguments.setInt(1);
+ return;
+ }
+
+ unsigned Size = sizeof(TemplateArgument) * NumTemplateArgs;
+ unsigned Align = llvm::AlignOf<TemplateArgument>::Alignment;
+ void *Mem = Context.Allocate(Size, Align);
+ Arguments.setPointer((TemplateArgument *)Mem);
+ Arguments.setInt(0);
+
+ TemplateArgument *Args = (TemplateArgument *)Mem;
+ for (unsigned I = 0; I != NumTemplateArgs; ++I)
+ new (Args + I) TemplateArgument(TemplateArgs[I]);
+}
+
+TemplateArgumentList::~TemplateArgumentList() {
+ // FIXME: Deallocate template arguments
+}
+
//===----------------------------------------------------------------------===//
// ClassTemplateSpecializationDecl Implementation
//===----------------------------------------------------------------------===//
ClassTemplateSpecializationDecl::
-ClassTemplateSpecializationDecl(DeclContext *DC, SourceLocation L,
+ClassTemplateSpecializationDecl(ASTContext &Context,
+ DeclContext *DC, SourceLocation L,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgument *TemplateArgs,
+ TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs)
: CXXRecordDecl(ClassTemplateSpecialization,
SpecializedTemplate->getTemplatedDecl()->getTagKind(),
// class template specializations?
SpecializedTemplate->getIdentifier()),
SpecializedTemplate(SpecializedTemplate),
- NumTemplateArgs(NumTemplateArgs), SpecializationKind(TSK_Undeclared) {
- TemplateArgument *Arg = reinterpret_cast<TemplateArgument *>(this + 1);
- for (unsigned ArgIdx = 0; ArgIdx < NumTemplateArgs; ++ArgIdx, ++Arg)
- new (Arg) TemplateArgument(TemplateArgs[ArgIdx]);
+ TemplateArgs(Context, TemplateArgs, NumTemplateArgs, /*CopyArgs=*/true),
+ SpecializationKind(TSK_Undeclared) {
}
ClassTemplateSpecializationDecl *
TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
ClassTemplateSpecializationDecl *PrevDecl) {
- unsigned Size = sizeof(ClassTemplateSpecializationDecl) +
- sizeof(TemplateArgument) * NumTemplateArgs;
- unsigned Align = llvm::AlignOf<ClassTemplateSpecializationDecl>::Alignment;
- void *Mem = Context.Allocate(Size, Align);
ClassTemplateSpecializationDecl *Result
- = new (Mem) ClassTemplateSpecializationDecl(DC, L, SpecializedTemplate,
- TemplateArgs, NumTemplateArgs);
+ = new (Context)ClassTemplateSpecializationDecl(Context, DC, L,
+ SpecializedTemplate,
+ TemplateArgs,
+ NumTemplateArgs);
Context.getTypeDeclType(Result, PrevDecl);
return Result;
}
// arguments.
if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(getDecl())) {
- std::string TemplateArgs
+ const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
+ std::string TemplateArgsStr
= TemplateSpecializationType::PrintTemplateArgumentList(
- Spec->getTemplateArgs(),
- Spec->getNumTemplateArgs());
- InnerString = TemplateArgs + InnerString;
+ TemplateArgs.getFlatArgumentList(),
+ TemplateArgs.flat_size());
+ InnerString = TemplateArgsStr + InnerString;
}
if (Kind) {
MyPart = NS->getNameAsString();
} else if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
- std::string TemplateArgs
+ const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
+ std::string TemplateArgsStr
= TemplateSpecializationType::PrintTemplateArgumentList(
- Spec->getTemplateArgs(),
- Spec->getNumTemplateArgs());
- MyPart = Spec->getIdentifier()->getName() + TemplateArgs;
+ TemplateArgs.getFlatArgumentList(),
+ TemplateArgs.flat_size());
+ MyPart = Spec->getIdentifier()->getName() + TemplateArgsStr;
} else if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) {
if (TypedefDecl *Typedef = Tag->getTypedefForAnonDecl())
MyPart = Typedef->getIdentifier()->getName();
class TypedefDecl;
class TemplateDecl;
class TemplateArgument;
+ class TemplateArgumentList;
class TemplateParameterList;
class TemplateTemplateParmDecl;
class ClassTemplateDecl;
uintptr_t Entity;
// \brief If this the instantiation of a default template
- // argument, the list of tempalte arguments.
+ // argument, the list of template arguments.
const TemplateArgument *TemplateArgs;
/// \brief The number of template arguments in TemplateArgs.
void PrintInstantiationStack();
- QualType InstantiateType(QualType T, const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
+ QualType InstantiateType(QualType T, const TemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity);
OwningExprResult InstantiateExpr(Expr *E,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs);
+ const TemplateArgumentList &TemplateArgs);
Decl *InstantiateDecl(Decl *D, DeclContext *Owner,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs);
+ const TemplateArgumentList &TemplateArgs);
bool
InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs);
+ const TemplateArgumentList &TemplateArgs);
bool
InstantiateClass(SourceLocation PointOfInstantiation,
CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs);
+ const TemplateArgumentList &TemplateArgs);
bool
InstantiateClassTemplateSpecialization(
NestedNameSpecifier *
InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs);
+ const TemplateArgumentList &TemplateArgs);
TemplateName
InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs);
+ const TemplateArgumentList &TemplateArgs);
// Simple function for cloning expressions.
template<typename T>
Template, &Converted[0],
Converted.size(),
SourceRange(TemplateLoc, RAngleLoc));
- ArgType = InstantiateType(ArgType, &Converted[0], Converted.size(),
+
+ TemplateArgumentList TemplateArgs(Context, &Converted[0],
+ Converted.size(),
+ /*CopyArgs=*/false);
+ ArgType = InstantiateType(ArgType, TemplateArgs,
TTP->getDefaultArgumentLoc(),
TTP->getDeclName());
}
Converted.size(),
SourceRange(TemplateLoc, RAngleLoc));
- NTTPType = InstantiateType(NTTPType,
- &Converted[0], Converted.size(),
+ TemplateArgumentList TemplateArgs(Context, &Converted[0],
+ Converted.size(),
+ /*CopyArgs=*/false);
+ NTTPType = InstantiateType(NTTPType, TemplateArgs,
NTTP->getLocation(),
NTTP->getDeclName());
// If that worked, check the non-type template parameter type
namespace {
class VISIBILITY_HIDDEN TemplateTypeInstantiator {
Sema &SemaRef;
- const TemplateArgument *TemplateArgs;
- unsigned NumTemplateArgs;
+ const TemplateArgumentList &TemplateArgs;
SourceLocation Loc;
DeclarationName Entity;
public:
TemplateTypeInstantiator(Sema &SemaRef,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
+ const TemplateArgumentList &TemplateArgs,
SourceLocation Loc,
DeclarationName Entity)
: SemaRef(SemaRef), TemplateArgs(TemplateArgs),
- NumTemplateArgs(NumTemplateArgs), Loc(Loc), Entity(Entity) { }
+ Loc(Loc), Entity(Entity) { }
QualType operator()(QualType T) const { return Instantiate(T); }
// Instantiate the size expression
Sema::OwningExprResult InstantiatedArraySize =
- SemaRef.InstantiateExpr(ArraySize, TemplateArgs, NumTemplateArgs);
+ SemaRef.InstantiateExpr(ArraySize, TemplateArgs);
if (InstantiatedArraySize.isInvalid())
return QualType();
if (T->getDepth() == 0) {
// Replace the template type parameter with its corresponding
// template argument.
- assert(T->getIndex() < NumTemplateArgs && "Wrong # of template args");
assert(TemplateArgs[T->getIndex()].getKind() == TemplateArgument::Type &&
"Template argument kind mismatch");
QualType Result = TemplateArgs[T->getIndex()].getAsType();
switch (Arg->getKind()) {
case TemplateArgument::Type: {
QualType T = SemaRef.InstantiateType(Arg->getAsType(),
- TemplateArgs, NumTemplateArgs,
+ TemplateArgs,
Arg->getLocation(),
DeclarationName());
if (T.isNull())
case TemplateArgument::Expression:
Sema::OwningExprResult E
- = SemaRef.InstantiateExpr(Arg->getAsExpr(), TemplateArgs,
- NumTemplateArgs);
+ = SemaRef.InstantiateExpr(Arg->getAsExpr(), TemplateArgs);
if (E.isInvalid())
return QualType();
InstantiatedTemplateArgs.push_back(E.takeAs<Expr>());
TemplateName Name = SemaRef.InstantiateTemplateName(T->getTemplateName(),
Loc,
- TemplateArgs,
- NumTemplateArgs);
+ TemplateArgs);
return SemaRef.CheckTemplateIdType(Name, Loc, SourceLocation(),
&InstantiatedTemplateArgs[0],
NestedNameSpecifier *NNS
= SemaRef.InstantiateNestedNameSpecifier(T->getQualifier(),
SourceRange(Loc),
- TemplateArgs, NumTemplateArgs);
+ TemplateArgs);
if (!NNS)
return QualType();
/// \param TemplateArgs the template arguments that will be
/// substituted for the top-level template parameters within T.
///
-/// \param NumTemplateArgs the number of template arguments provided
-/// by TemplateArgs.
-///
/// \param Loc the location in the source code where this substitution
/// is being performed. It will typically be the location of the
/// declarator (if we're instantiating the type of some declaration)
/// \returns If the instantiation succeeds, the instantiated
/// type. Otherwise, produces diagnostics and returns a NULL type.
QualType Sema::InstantiateType(QualType T,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
+ const TemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity) {
assert(!ActiveTemplateInstantiations.empty() &&
"Cannot perform an instantiation without some context on the "
if (!T->isDependentType())
return T;
- TemplateTypeInstantiator Instantiator(*this, TemplateArgs, NumTemplateArgs,
- Loc, Entity);
+ TemplateTypeInstantiator Instantiator(*this, TemplateArgs, Loc, Entity);
return Instantiator(T);
}
bool
Sema::InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs) {
+ const TemplateArgumentList &TemplateArgs) {
bool Invalid = false;
llvm::SmallVector<CXXBaseSpecifier*, 8> InstantiatedBases;
for (ClassTemplateSpecializationDecl::base_class_iterator
}
QualType BaseType = InstantiateType(Base->getType(),
- TemplateArgs, NumTemplateArgs,
+ TemplateArgs,
Base->getSourceRange().getBegin(),
DeclarationName());
if (BaseType.isNull()) {
/// \param TemplateArgs The template arguments to be substituted into
/// the pattern.
///
-/// \param NumTemplateArgs The number of templates arguments in
-/// TemplateArgs.
-///
/// \returns true if an error occurred, false otherwise.
bool
Sema::InstantiateClass(SourceLocation PointOfInstantiation,
CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs) {
+ const TemplateArgumentList &TemplateArgs) {
bool Invalid = false;
CXXRecordDecl *PatternDef
Instantiation->startDefinition();
// Instantiate the base class specifiers.
- if (InstantiateBaseSpecifiers(Instantiation, Pattern, TemplateArgs,
- NumTemplateArgs))
+ if (InstantiateBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
Invalid = true;
llvm::SmallVector<DeclPtrTy, 32> Fields;
for (RecordDecl::decl_iterator Member = Pattern->decls_begin(Context),
MemberEnd = Pattern->decls_end(Context);
Member != MemberEnd; ++Member) {
- Decl *NewMember = InstantiateDecl(*Member, Instantiation,
- TemplateArgs, NumTemplateArgs);
+ Decl *NewMember = InstantiateDecl(*Member, Instantiation, TemplateArgs);
if (NewMember) {
if (NewMember->isInvalidDecl())
Invalid = true;
return InstantiateClass(ClassTemplateSpec->getLocation(),
ClassTemplateSpec, Pattern,
- ClassTemplateSpec->getTemplateArgs(),
- ClassTemplateSpec->getNumTemplateArgs());
+ ClassTemplateSpec->getTemplateArgs());
}
/// \brief Instantiate a nested-name-specifier.
NestedNameSpecifier *
Sema::InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs) {
+ const TemplateArgumentList &TemplateArgs) {
// Instantiate the prefix of this nested name specifier.
NestedNameSpecifier *Prefix = NNS->getPrefix();
if (Prefix) {
- Prefix = InstantiateNestedNameSpecifier(Prefix, Range, TemplateArgs,
- NumTemplateArgs);
+ Prefix = InstantiateNestedNameSpecifier(Prefix, Range, TemplateArgs);
if (!Prefix)
return 0;
}
if (!T->isDependentType())
return NNS;
- T = InstantiateType(T, TemplateArgs, NumTemplateArgs, Range.getBegin(),
- DeclarationName());
+ T = InstantiateType(T, TemplateArgs, Range.getBegin(), DeclarationName());
if (T.isNull())
return 0;
TemplateName
Sema::InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs) {
+ const TemplateArgumentList &TemplateArgs) {
if (TemplateTemplateParmDecl *TTP
= dyn_cast_or_null<TemplateTemplateParmDecl>(
Name.getAsTemplateDecl())) {
assert(TTP->getDepth() == 0 &&
"Cannot reduce depth of a template template parameter");
- assert(TTP->getPosition() < NumTemplateArgs && "Wrong # of template args");
assert(TemplateArgs[TTP->getPosition()].getAsDecl() &&
"Wrong kind of template template argument");
ClassTemplateDecl *ClassTemplate
NestedNameSpecifier *NNS
= InstantiateNestedNameSpecifier(QTN->getQualifier(),
/*FIXME=*/SourceRange(Loc),
- TemplateArgs, NumTemplateArgs);
+ TemplateArgs);
if (NNS)
return Context.getQualifiedTemplateName(NNS,
QTN->hasTemplateKeyword(),
NestedNameSpecifier *NNS
= InstantiateNestedNameSpecifier(DTN->getQualifier(),
/*FIXME=*/SourceRange(Loc),
- TemplateArgs, NumTemplateArgs);
+ TemplateArgs);
if (!NNS) // FIXME: Not the best recovery strategy.
return Name;
: public DeclVisitor<TemplateDeclInstantiator, Decl *> {
Sema &SemaRef;
DeclContext *Owner;
- const TemplateArgument *TemplateArgs;
- unsigned NumTemplateArgs;
+ const TemplateArgumentList &TemplateArgs;
public:
typedef Sema::OwningExprResult OwningExprResult;
TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs)
- : SemaRef(SemaRef), Owner(Owner), TemplateArgs(TemplateArgs),
- NumTemplateArgs(NumTemplateArgs) { }
+ const TemplateArgumentList &TemplateArgs)
+ : SemaRef(SemaRef), Owner(Owner), TemplateArgs(TemplateArgs) { }
// FIXME: Once we get closer to completion, replace these
// manually-written declarations with automatically-generated ones
bool Invalid = false;
QualType T = D->getUnderlyingType();
if (T->isDependentType()) {
- T = SemaRef.InstantiateType(T, TemplateArgs, NumTemplateArgs,
- D->getLocation(),
+ T = SemaRef.InstantiateType(T, TemplateArgs, D->getLocation(),
D->getDeclName());
if (T.isNull()) {
Invalid = true;
Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
// Instantiate the type of the declaration
QualType T = SemaRef.InstantiateType(D->getType(), TemplateArgs,
- NumTemplateArgs,
D->getTypeSpecStartLoc(),
D->getDeclName());
if (T.isNull())
if (D->getInit()) {
OwningExprResult Init
- = SemaRef.InstantiateExpr(D->getInit(), TemplateArgs, NumTemplateArgs);
+ = SemaRef.InstantiateExpr(D->getInit(), TemplateArgs);
if (Init.isInvalid())
Var->setInvalidDecl();
else
bool Invalid = false;
QualType T = D->getType();
if (T->isDependentType()) {
- T = SemaRef.InstantiateType(T, TemplateArgs, NumTemplateArgs,
- D->getLocation(),
+ T = SemaRef.InstantiateType(T, TemplateArgs, D->getLocation(),
D->getDeclName());
if (!T.isNull() && T->isFunctionType()) {
// C++ [temp.arg.type]p3:
BitWidth = 0;
else if (BitWidth) {
OwningExprResult InstantiatedBitWidth
- = SemaRef.InstantiateExpr(BitWidth, TemplateArgs, NumTemplateArgs);
+ = SemaRef.InstantiateExpr(BitWidth, TemplateArgs);
if (InstantiatedBitWidth.isInvalid()) {
Invalid = true;
BitWidth = 0;
Expr *AssertExpr = D->getAssertExpr();
OwningExprResult InstantiatedAssertExpr
- = SemaRef.InstantiateExpr(AssertExpr, TemplateArgs, NumTemplateArgs);
+ = SemaRef.InstantiateExpr(AssertExpr, TemplateArgs);
if (InstantiatedAssertExpr.isInvalid())
return 0;
// The specified value for the enumerator.
OwningExprResult Value = SemaRef.Owned((Expr *)0);
if (Expr *UninstValue = EC->getInitExpr())
- Value = SemaRef.InstantiateExpr(UninstValue,
- TemplateArgs, NumTemplateArgs);
+ Value = SemaRef.InstantiateExpr(UninstValue, TemplateArgs);
// Drop the initial value and continue.
bool isInvalid = false;
ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
QualType OrigT = SemaRef.InstantiateType(D->getOriginalType(), TemplateArgs,
- NumTemplateArgs, D->getLocation(),
- D->getDeclName());
+ D->getLocation(), D->getDeclName());
if (OrigT.isNull())
return 0;
}
Decl *Sema::InstantiateDecl(Decl *D, DeclContext *Owner,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs) {
- TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs,
- NumTemplateArgs);
+ const TemplateArgumentList &TemplateArgs) {
+ TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs);
return Instantiator.Visit(D);
}
bool InvalidDecl = false;
// Instantiate the function parameters
- TemplateDeclInstantiator ParamInstantiator(SemaRef, 0,
- TemplateArgs, NumTemplateArgs);
+ TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs);
llvm::SmallVector<QualType, 16> ParamTys;
for (FunctionDecl::param_iterator P = D->param_begin(),
PEnd = D->param_end();
const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType();
assert(Proto && "Missing prototype?");
QualType ResultType
- = SemaRef.InstantiateType(Proto->getResultType(),
- TemplateArgs, NumTemplateArgs,
+ = SemaRef.InstantiateType(Proto->getResultType(), TemplateArgs,
D->getLocation(), D->getDeclName());
if (ResultType.isNull())
return QualType();
class VISIBILITY_HIDDEN TemplateExprInstantiator
: public StmtVisitor<TemplateExprInstantiator, Sema::OwningExprResult> {
Sema &SemaRef;
- const TemplateArgument *TemplateArgs;
- unsigned NumTemplateArgs;
+ const TemplateArgumentList &TemplateArgs;
public:
typedef Sema::OwningExprResult OwningExprResult;
TemplateExprInstantiator(Sema &SemaRef,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs)
- : SemaRef(SemaRef), TemplateArgs(TemplateArgs),
- NumTemplateArgs(NumTemplateArgs) { }
+ const TemplateArgumentList &TemplateArgs)
+ : SemaRef(SemaRef), TemplateArgs(TemplateArgs) { }
// FIXME: Once we get closer to completion, replace these
// manually-written declarations with automatically-generated ones
if (E->isArgumentType()) {
QualType T = E->getArgumentType();
if (T->isDependentType()) {
- T = SemaRef.InstantiateType(T, TemplateArgs, NumTemplateArgs,
+ T = SemaRef.InstantiateType(T, TemplateArgs,
/*FIXME*/E->getOperatorLoc(),
&SemaRef.PP.getIdentifierTable().get("sizeof"));
if (T.isNull())
NestedNameSpecifier *NNS
= SemaRef.InstantiateNestedNameSpecifier(E->getQualifier(),
E->getQualifierRange(),
- TemplateArgs, NumTemplateArgs);
+ TemplateArgs);
if (!NNS)
return SemaRef.ExprError();
CXXTemporaryObjectExpr *E) {
QualType T = E->getType();
if (T->isDependentType()) {
- T = SemaRef.InstantiateType(T, TemplateArgs, NumTemplateArgs,
+ T = SemaRef.InstantiateType(T, TemplateArgs,
E->getTypeBeginLoc(), DeclarationName());
if (T.isNull())
return SemaRef.ExprError();
}
Sema::OwningExprResult
-Sema::InstantiateExpr(Expr *E, const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs) {
- TemplateExprInstantiator Instantiator(*this, TemplateArgs, NumTemplateArgs);
+Sema::InstantiateExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
+ TemplateExprInstantiator Instantiator(*this, TemplateArgs);
return Instantiator.Visit(E);
}
Parent && !Spec; Parent = Parent->getParent())
Spec = dyn_cast<ClassTemplateSpecializationDecl>(Parent);
assert(Spec && "Not a member of a class template specialization?");
- return InstantiateClass(Loc, Rec, Pattern,
- Spec->getTemplateArgs(),
- Spec->getNumTemplateArgs());
+ return InstantiateClass(Loc, Rec, Pattern, Spec->getTemplateArgs());
}
}
}