diff options
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 13 | ||||
-rw-r--r-- | lib/AST/DeclPrinter.cpp | 3 | ||||
-rw-r--r-- | lib/AST/DeclTemplate.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 3 |
4 files changed, 18 insertions, 6 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 5bbfbceed9..c301d4608d 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -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; diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index f231abf89e..2b06e93295 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -527,6 +527,9 @@ void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) { else Out << "class "; + if (TTP->isParameterPack()) + Out << "... "; + Out << ParamType.getAsString(Policy); if (TTP->hasDefaultArgument()) { diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index a53416433e..a0773f12d7 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -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); } //===----------------------------------------------------------------------===// diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index ec2907f65a..8058ad2d63 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -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(); |