]> granicus.if.org Git - clang/commitdiff
Keep track of whether a type parameter is actually a type parameter pack.
authorAnders Carlsson <andersca@mac.com>
Fri, 12 Jun 2009 22:23:22 +0000 (22:23 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 12 Jun 2009 22:23:22 +0000 (22:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73261 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclTemplate.h
lib/AST/DeclPrinter.cpp
lib/AST/DeclTemplate.cpp
lib/Sema/SemaTemplate.cpp

index 5bbfbceed9708a68d06a363eaef4876cbcb2bae0..c301d4608d59fce264d32611cd15db93b574d148 100644 (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;
index f231abf89e01e7b8e64f28c9b59bd8cb91a9bd1d..2b06e93295bcaa6589835afd93ad3eab8259a6c4 100644 (file)
@@ -527,6 +527,9 @@ void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) {
       else
         Out << "class ";
 
+      if (TTP->isParameterPack())
+        Out << "... ";
+      
       Out << ParamType.getAsString(Policy);
 
       if (TTP->hasDefaultArgument()) {
index a53416433e03a501df237f7c2384af60a5b151a6..a0773f12d75d1f9e6a42a7a93575a56936378d34 100644 (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);
 }
 
 //===----------------------------------------------------------------------===//
index ec2907f65a76e66ba7c5e30c5fc66c5a072229d3..8058ad2d63fc68a0bd97ebbe40c4cb44f0d810c8 100644 (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();