Keep track of whether a type parameter is actually a type parameter pack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73261 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 5bbfbce..c301d46 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -233,6 +233,9 @@
/// 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 @@
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 @@
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 f231abf..2b06e93 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -527,6 +527,9 @@
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 a534164..a0773f1 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -186,9 +186,10 @@
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 ec2907f..8058ad2 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -163,7 +163,8 @@
TemplateTypeParmDecl *Param
= TemplateTypeParmDecl::Create(Context, CurContext, Loc,
- Depth, Position, ParamName, Typename);
+ Depth, Position, ParamName, Typename,
+ Ellipsis);
if (Invalid)
Param->setInvalidDecl();