[cfe-commits] r73452 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/AST/DeclTemplate.cpp lib/Sema/SemaTemplateInstantiate.cpp

Anders Carlsson andersca at mac.com
Mon Jun 15 17:30:48 PDT 2009


Author: andersca
Date: Mon Jun 15 19:30:48 2009
New Revision: 73452

URL: http://llvm.org/viewvc/llvm-project?rev=73452&view=rev
Log:
Keep track of whether a type parameter type is a parameter pack.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/DeclTemplate.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=73452&r1=73451&r2=73452&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jun 15 19:30:48 2009
@@ -299,6 +299,7 @@
   QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl);
 
   QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, 
+                                   bool ParameterPack,
                                    IdentifierInfo *Name = 0);
 
   QualType getTemplateSpecializationType(TemplateName T,

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=73452&r1=73451&r2=73452&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Jun 15 19:30:48 2009
@@ -1403,36 +1403,40 @@
 };
 
 class TemplateTypeParmType : public Type, public llvm::FoldingSetNode {
-  unsigned Depth : 16;
+  unsigned Depth : 15;
   unsigned Index : 16;
+  unsigned ParameterPack : 1;
   IdentifierInfo *Name;
 
-  TemplateTypeParmType(unsigned D, unsigned I, IdentifierInfo *N, 
+  TemplateTypeParmType(unsigned D, unsigned I, bool PP, IdentifierInfo *N, 
                        QualType Canon) 
     : Type(TemplateTypeParm, Canon, /*Dependent=*/true),
-      Depth(D), Index(I), Name(N) { }
+      Depth(D), Index(I), ParameterPack(PP), Name(N) { }
 
-  TemplateTypeParmType(unsigned D, unsigned I) 
+  TemplateTypeParmType(unsigned D, unsigned I, bool PP) 
     : Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true),
-      Depth(D), Index(I), Name(0) { }
+      Depth(D), Index(I), ParameterPack(PP), Name(0) { }
 
   friend class ASTContext;  // ASTContext creates these
 
 public:
   unsigned getDepth() const { return Depth; }
   unsigned getIndex() const { return Index; }
+  bool isParameterPack() const { return ParameterPack; }
   IdentifierInfo *getName() const { return Name; }
   
   virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
-    Profile(ID, Depth, Index, Name);
+    Profile(ID, Depth, Index, ParameterPack, Name);
   }
 
   static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth, 
-                      unsigned Index, IdentifierInfo *Name) {
+                      unsigned Index, bool ParameterPack, 
+                      IdentifierInfo *Name) {
     ID.AddInteger(Depth);
     ID.AddInteger(Index);
+    ID.AddBoolean(ParameterPack);
     ID.AddPointer(Name);
   }
 

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=73452&r1=73451&r2=73452&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Jun 15 19:30:48 2009
@@ -1414,11 +1414,13 @@
 }
 
 /// \brief Retrieve the template type parameter type for a template
-/// parameter with the given depth, index, and (optionally) name.
+/// parameter or parameter pack with the given depth, index, and (optionally) 
+/// name.
 QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index, 
+                                             bool ParameterPack,
                                              IdentifierInfo *Name) {
   llvm::FoldingSetNodeID ID;
-  TemplateTypeParmType::Profile(ID, Depth, Index, Name);
+  TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, Name);
   void *InsertPos = 0;
   TemplateTypeParmType *TypeParm 
     = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -1426,11 +1428,12 @@
   if (TypeParm)
     return QualType(TypeParm, 0);
   
-  if (Name)
-    TypeParm = new (*this, 8) TemplateTypeParmType(Depth, Index, Name,
-                                         getTemplateTypeParmType(Depth, Index));
-  else
-    TypeParm = new (*this, 8) TemplateTypeParmType(Depth, Index);
+  if (Name) {
+    QualType Canon = getTemplateTypeParmType(Depth, Index, ParameterPack);
+    TypeParm = new (*this, 8) TemplateTypeParmType(Depth, Index, ParameterPack,
+                                                   Name, Canon);
+  } else
+    TypeParm = new (*this, 8) TemplateTypeParmType(Depth, Index, ParameterPack);
 
   Types.push_back(TypeParm);
   TemplateTypeParmTypes.InsertNode(TypeParm, InsertPos);

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=73452&r1=73451&r2=73452&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Mon Jun 15 19:30:48 2009
@@ -190,7 +190,7 @@
                              SourceLocation L, unsigned D, unsigned P,
                              IdentifierInfo *Id, bool Typename,
                              bool ParameterPack) {
-  QualType Type = C.getTemplateTypeParmType(D, P, Id);
+  QualType Type = C.getTemplateTypeParmType(D, P, ParameterPack, Id);
   return new (C) TemplateTypeParmDecl(DC, L, Id, Typename, Type, ParameterPack);
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=73452&r1=73451&r2=73452&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Jun 15 19:30:48 2009
@@ -564,6 +564,7 @@
   // parameter with the template "level" reduced by one.
   return SemaRef.Context.getTemplateTypeParmType(T->getDepth() - 1,
                                                  T->getIndex(),
+                                                 T->isParameterPack(),
                                                  T->getName())
     .getQualifiedType(Quals);
 }





More information about the cfe-commits mailing list