]> granicus.if.org Git - clang/commitdiff
TemplateSpecializationType's isCurrentInstantiation bit can be derived
authorJohn McCall <rjmccall@apple.com>
Sun, 13 Jun 2010 09:25:03 +0000 (09:25 +0000)
committerJohn McCall <rjmccall@apple.com>
Sun, 13 Jun 2010 09:25:03 +0000 (09:25 +0000)
from its canonical type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105912 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
include/clang/AST/Type.h
lib/AST/ASTContext.cpp
lib/AST/Type.cpp
lib/Sema/SemaTemplate.cpp

index b69d27613e548535909cae1db0b6b1a48ac7ca25..9d0469368f39e0f3fad65c5068faf1d6e9620766 100644 (file)
@@ -606,13 +606,11 @@ public:
   QualType getTemplateSpecializationType(TemplateName T,
                                          const TemplateArgument *Args,
                                          unsigned NumArgs,
-                                         QualType Canon = QualType(),
-                                         bool IsCurrentInstantiation = false);
+                                         QualType Canon = QualType());
 
   QualType getTemplateSpecializationType(TemplateName T,
                                          const TemplateArgumentListInfo &Args,
-                                         QualType Canon = QualType(),
-                                         bool IsCurrentInstantiation = false);
+                                         QualType Canon = QualType());
 
   TypeSourceInfo *
   getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc,
index c6d3f996edf3ec0cf869bbdd8aa4d1ea7a52f167..7fa747b62e24847504c0404cfdfef5fff1ddf60a 100644 (file)
@@ -2419,10 +2419,6 @@ public:
 /// dependent.
 class TemplateSpecializationType
   : public Type, public llvm::FoldingSetNode {
-
-  // The bool is whether this is a current instantiation.
-  bool IsCurrentInstantiation;
-
   /// \brief The name of the template being specialized.
   TemplateName Template;
 
@@ -2431,7 +2427,6 @@ class TemplateSpecializationType
   unsigned NumArgs;
 
   TemplateSpecializationType(TemplateName T,
-                             bool IsCurrentInstantiation,
                              const TemplateArgument *Args,
                              unsigned NumArgs, QualType Canon);
 
@@ -2466,7 +2461,7 @@ public:
   /// True if this template specialization type matches a current
   /// instantiation in the context in which it is found.
   bool isCurrentInstantiation() const {
-    return IsCurrentInstantiation;
+    return isa<InjectedClassNameType>(getCanonicalTypeInternal());
   }
 
   typedef const TemplateArgument * iterator;
@@ -2495,11 +2490,10 @@ public:
   QualType desugar() const { return getCanonicalTypeInternal(); }
 
   void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Ctx) {
-    Profile(ID, Template, isCurrentInstantiation(), getArgs(), NumArgs, Ctx);
+    Profile(ID, Template, getArgs(), NumArgs, Ctx);
   }
 
   static void Profile(llvm::FoldingSetNodeID &ID, TemplateName T,
-                      bool IsCurrentInstantiation,
                       const TemplateArgument *Args,
                       unsigned NumArgs,
                       ASTContext &Context);
index 065ebe9f9a0bb180765cbec046549a05fa3bf18d..bb27ab9747ded4f5009284c498245cf937ab1a40 100644 (file)
@@ -1778,8 +1778,7 @@ ASTContext::getTemplateSpecializationTypeInfo(TemplateName Name,
 QualType
 ASTContext::getTemplateSpecializationType(TemplateName Template,
                                           const TemplateArgumentListInfo &Args,
-                                          QualType Canon,
-                                          bool IsCurrentInstantiation) {
+                                          QualType Canon) {
   unsigned NumArgs = Args.size();
 
   llvm::SmallVector<TemplateArgument, 4> ArgVec;
@@ -1788,22 +1787,17 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
     ArgVec.push_back(Args[i].getArgument());
 
   return getTemplateSpecializationType(Template, ArgVec.data(), NumArgs,
-                                       Canon, IsCurrentInstantiation);
+                                       Canon);
 }
 
 QualType
 ASTContext::getTemplateSpecializationType(TemplateName Template,
                                           const TemplateArgument *Args,
                                           unsigned NumArgs,
-                                          QualType Canon,
-                                          bool IsCurrentInstantiation) {
+                                          QualType Canon) {
   if (!Canon.isNull())
     Canon = getCanonicalType(Canon);
   else {
-    assert(!IsCurrentInstantiation &&
-           "current-instantiation specializations should always "
-           "have a canonical type");
-
     // Build the canonical template specialization type.
     TemplateName CanonTemplate = getCanonicalTemplateName(Template);
     llvm::SmallVector<TemplateArgument, 4> CanonArgs;
@@ -1814,7 +1808,7 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
     // Determine whether this canonical template specialization type already
     // exists.
     llvm::FoldingSetNodeID ID;
-    TemplateSpecializationType::Profile(ID, CanonTemplate, false,
+    TemplateSpecializationType::Profile(ID, CanonTemplate,
                                         CanonArgs.data(), NumArgs, *this);
 
     void *InsertPos = 0;
@@ -1826,7 +1820,7 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
       void *Mem = Allocate((sizeof(TemplateSpecializationType) +
                             sizeof(TemplateArgument) * NumArgs),
                            TypeAlignment);
-      Spec = new (Mem) TemplateSpecializationType(CanonTemplate, false,
+      Spec = new (Mem) TemplateSpecializationType(CanonTemplate,
                                                   CanonArgs.data(), NumArgs,
                                                   Canon);
       Types.push_back(Spec);
@@ -1847,7 +1841,6 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
                        TypeAlignment);
   TemplateSpecializationType *Spec
     = new (Mem) TemplateSpecializationType(Template,
-                                           IsCurrentInstantiation,
                                            Args, NumArgs,
                                            Canon);
 
index 7a699b001553a267b9a83f7d57edebcaf90577d1..1d91e76c8f9994f6bac2bbc762b8acf4c62e8817 100644 (file)
@@ -1131,13 +1131,11 @@ anyDependentTemplateArguments(const TemplateArgument *Args, unsigned N) {
 
 TemplateSpecializationType::
 TemplateSpecializationType(TemplateName T,
-                           bool IsCurrentInstantiation,
                            const TemplateArgument *Args,
                            unsigned NumArgs, QualType Canon)
   : Type(TemplateSpecialization,
          Canon.isNull()? QualType(this, 0) : Canon,
          T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)),
-    IsCurrentInstantiation(IsCurrentInstantiation),
     Template(T), NumArgs(NumArgs) {
   assert((!Canon.isNull() ||
           T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)) &&
@@ -1161,11 +1159,9 @@ void TemplateSpecializationType::Destroy(ASTContext& C) {
 void
 TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
                                     TemplateName T,
-                                    bool IsCurrentInstantiation,
                                     const TemplateArgument *Args,
                                     unsigned NumArgs,
                                     ASTContext &Context) {
-  ID.AddBoolean(IsCurrentInstantiation);
   T.Profile(ID);
   for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
     Args[Idx].Profile(ID, Context);
index 6be74a089782e117aeebd1ef8ac8b731f026e701..0c75cda57e651870b6a785bd903c9ed5853e8890 100644 (file)
@@ -1448,7 +1448,6 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
          "Converted template argument list is too short!");
 
   QualType CanonType;
-  bool IsCurrentInstantiation = false;
 
   if (Name.isDependent() ||
       TemplateSpecializationType::anyDependentTemplateArguments(
@@ -1505,7 +1504,6 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
         // class name type of the record we just found.
         assert(ICNT.isCanonical());
         CanonType = ICNT;
-        IsCurrentInstantiation = true;
         break;
       }
     }
@@ -1543,8 +1541,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
   // Build the fully-sugared type for this class template
   // specialization, which refers back to the class template
   // specialization we created or found.
-  return Context.getTemplateSpecializationType(Name, TemplateArgs, CanonType,
-                                               IsCurrentInstantiation);
+  return Context.getTemplateSpecializationType(Name, TemplateArgs, CanonType);
 }
 
 Action::TypeResult