]> granicus.if.org Git - clang/commitdiff
Avoid setters in ASTDeclReader::VisitClassTemplateSpecializationDecl.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 13 Sep 2010 11:45:32 +0000 (11:45 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 13 Sep 2010 11:45:32 +0000 (11:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113742 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclTemplate.h
lib/Serialization/ASTReaderDecl.cpp

index cc7ac6b300c5bcc8e31d4c29d546dc484bdefd5a..a868b9c6a4f28b3e82dcfffb5c6b9bd059f1b2fc 100644 (file)
@@ -1280,14 +1280,6 @@ public:
     return TemplateArgs;
   }
 
-  /// \brief Initialize the template arguments of the class template
-  /// specialization.
-  void initTemplateArgs(TemplateArgument *Args, unsigned NumArgs) {
-    assert(TemplateArgs.flat_size() == 0 &&
-           "Template arguments already initialized!");
-    TemplateArgs.init(getASTContext(), Args, NumArgs);
-  }
-
   /// \brief Determine the kind of specialization that this
   /// declaration represents.
   TemplateSpecializationKind getSpecializationKind() const {
@@ -1375,18 +1367,6 @@ public:
     SpecializedTemplate = PS;
   }
 
-  /// \brief Note that this class template specialization is actually an
-  /// instantiation of the given class template partial specialization whose
-  /// template arguments have been deduced.
-  void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec,
-                          TemplateArgument *TemplateArgs,
-                          unsigned NumTemplateArgs) {
-    ASTContext &Ctx = getASTContext();
-    setInstantiationOf(PartialSpec,
-                       new (Ctx) TemplateArgumentList(Ctx, TemplateArgs,
-                                                      NumTemplateArgs));
-  }
-
   /// \brief Note that this class template specialization is an instantiation
   /// of the given class template.
   void setInstantiationOf(ClassTemplateDecl *TemplDecl) {
@@ -1458,6 +1438,9 @@ public:
   static bool classof(const ClassTemplatePartialSpecializationDecl *) {
     return true;
   }
+  
+  friend class ASTDeclReader;
+  friend class ASTDeclWriter;
 };
 
 class ClassTemplatePartialSpecializationDecl
index 6edf8bce9a072afe44e8a2dffdbd75869c1d02cd..fe07217574fc3bc1249b8938d2480342608e0af1 100644 (file)
@@ -959,32 +959,41 @@ void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
 void ASTDeclReader::VisitClassTemplateSpecializationDecl(
                                            ClassTemplateSpecializationDecl *D) {
   VisitCXXRecordDecl(D);
-
+  
+  ASTContext &C = *Reader.getContext();
   if (Decl *InstD = Reader.GetDecl(Record[Idx++])) {
     if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
-      D->setInstantiationOf(CTD);
+      D->SpecializedTemplate = CTD;
     } else {
       llvm::SmallVector<TemplateArgument, 8> TemplArgs;
       Reader.ReadTemplateArgumentList(TemplArgs, Cursor, Record, Idx);
-      D->setInstantiationOf(cast<ClassTemplatePartialSpecializationDecl>(InstD),
-                            TemplArgs.data(), TemplArgs.size());
+      TemplateArgumentList *ArgList
+          = new (C) TemplateArgumentList(C, TemplArgs.data(), TemplArgs.size());
+      ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
+          = new (C) ClassTemplateSpecializationDecl::
+                                             SpecializedPartialSpecialization();
+      PS->PartialSpecialization
+          = cast<ClassTemplatePartialSpecializationDecl>(InstD);
+      PS->TemplateArgs = ArgList;
+      D->SpecializedTemplate = PS;
     }
   }
 
   // Explicit info.
   if (TypeSourceInfo *TyInfo = Reader.GetTypeSourceInfo(Cursor, Record, Idx)) {
-    D->setTypeAsWritten(TyInfo);
-    D->setExternLoc(Reader.ReadSourceLocation(Record, Idx));
-    D->setTemplateKeywordLoc(Reader.ReadSourceLocation(Record, Idx));
+    ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo
+        = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
+    ExplicitInfo->TypeAsWritten = TyInfo;
+    ExplicitInfo->ExternLoc = Reader.ReadSourceLocation(Record, Idx);
+    ExplicitInfo->TemplateKeywordLoc = Reader.ReadSourceLocation(Record, Idx);
+    D->ExplicitInfo = ExplicitInfo;
   }
 
   llvm::SmallVector<TemplateArgument, 8> TemplArgs;
   Reader.ReadTemplateArgumentList(TemplArgs, Cursor, Record, Idx);
-  D->initTemplateArgs(TemplArgs.data(), TemplArgs.size());
-  SourceLocation POI = Reader.ReadSourceLocation(Record, Idx);
-  if (POI.isValid())
-    D->setPointOfInstantiation(POI);
-  D->setSpecializationKind((TemplateSpecializationKind)Record[Idx++]);
+  D->TemplateArgs.init(C, TemplArgs.data(), TemplArgs.size());
+  D->PointOfInstantiation = Reader.ReadSourceLocation(Record, Idx);
+  D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
 
   if (D->isCanonicalDecl()) { // It's kept in the folding set.
     ClassTemplateDecl *CanonPattern