Keep track of whether a type parameter is actually a type parameter pack.

llvm-svn: 73261
This commit is contained in:
Anders Carlsson 2009-06-12 22:23:22 +00:00
parent 30b0197169
commit fb1d776ff0
4 changed files with 18 additions and 6 deletions

View File

@ -233,6 +233,9 @@ class TemplateTypeParmDecl : public TypeDecl {
/// default argument.
bool InheritedDefault : 1;
/// \brief Whether this is a parameter pack.
bool ParameterPack : 1;
/// \brief The location of the default argument, if any.
SourceLocation DefaultArgumentLoc;
@ -240,16 +243,17 @@ class TemplateTypeParmDecl : public TypeDecl {
QualType DefaultArgument;
TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
bool Typename, QualType Type)
bool Typename, QualType Type, bool ParameterPack)
: TypeDecl(TemplateTypeParm, DC, L, Id), Typename(Typename),
InheritedDefault(false), DefaultArgument() {
InheritedDefault(false), ParameterPack(ParameterPack), DefaultArgument() {
TypeForDecl = Type.getTypePtr();
}
public:
static TemplateTypeParmDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, unsigned D, unsigned P,
IdentifierInfo *Id, bool Typename);
IdentifierInfo *Id, bool Typename,
bool ParameterPack);
/// \brief Whether this template type parameter was declared with
/// the 'typename' keyword. If not, it was declared with the 'class'
@ -280,6 +284,9 @@ public:
InheritedDefault = Inherited;
}
/// \brief Returns whether this is a parameter pack.
bool isParameterPack() const { return ParameterPack; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() == TemplateTypeParm;

View File

@ -527,6 +527,9 @@ void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) {
else
Out << "class ";
if (TTP->isParameterPack())
Out << "... ";
Out << ParamType.getAsString(Policy);
if (TTP->hasDefaultArgument()) {

View File

@ -186,9 +186,10 @@ QualType ClassTemplateDecl::getInjectedClassNameType(ASTContext &Context) {
TemplateTypeParmDecl *
TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L, unsigned D, unsigned P,
IdentifierInfo *Id, bool Typename) {
IdentifierInfo *Id, bool Typename,
bool ParameterPack) {
QualType Type = C.getTemplateTypeParmType(D, P, Id);
return new (C) TemplateTypeParmDecl(DC, L, Id, Typename, Type);
return new (C) TemplateTypeParmDecl(DC, L, Id, Typename, Type, ParameterPack);
}
//===----------------------------------------------------------------------===//

View File

@ -163,7 +163,8 @@ Sema::DeclPtrTy Sema::ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
TemplateTypeParmDecl *Param
= TemplateTypeParmDecl::Create(Context, CurContext, Loc,
Depth, Position, ParamName, Typename);
Depth, Position, ParamName, Typename,
Ellipsis);
if (Invalid)
Param->setInvalidDecl();