[cfe-commits] r113743 - in /cfe/trunk: include/clang/AST/DeclTemplate.h lib/AST/DeclTemplate.cpp lib/Serialization/ASTReaderDecl.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Sep 13 04:45:41 PDT 2010


Author: akirtzidis
Date: Mon Sep 13 06:45:41 2010
New Revision: 113743

URL: http://llvm.org/viewvc/llvm-project?rev=113743&view=rev
Log:
Avoid setters in ASTDeclReader::VisitClassTemplatePartialSpecializationDecl.

Modified:
    cfe/trunk/include/clang/AST/DeclTemplate.h
    cfe/trunk/lib/AST/DeclTemplate.cpp
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=113743&r1=113742&r2=113743&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Mon Sep 13 06:45:41 2010
@@ -1513,18 +1513,11 @@
     return TemplateParams;
   }
 
-  void initTemplateParameters(TemplateParameterList *Params) {
-    assert(TemplateParams == 0 && "TemplateParams already set");
-    TemplateParams = Params;
-  }
-
   /// Get the template arguments as written.
   TemplateArgumentLoc *getTemplateArgsAsWritten() const {
     return ArgsAsWritten;
   }
 
-  void initTemplateArgsAsWritten(const TemplateArgumentListInfo &ArgInfos);
-
   /// Get the number of template arguments as written.
   unsigned getNumTemplateArgsAsWritten() const {
     return NumArgsAsWritten;
@@ -1533,8 +1526,7 @@
   /// \brief Get the sequence number for this class template partial
   /// specialization.
   unsigned getSequenceNumber() const { return SequenceNumber; }
-  void setSequenceNumber(unsigned N) { SequenceNumber = N; }
-    
+
   /// \brief Retrieve the member class template partial specialization from
   /// which this particular class template partial specialization was
   /// instantiated.
@@ -1618,6 +1610,9 @@
   static bool classof(const ClassTemplatePartialSpecializationDecl *) {
     return true;
   }
+
+  friend class ASTDeclReader;
+  friend class ASTDeclWriter;
 };
 
 /// Declaration of a class template.

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=113743&r1=113742&r2=113743&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Mon Sep 13 06:45:41 2010
@@ -577,19 +577,6 @@
   return new (Context)ClassTemplatePartialSpecializationDecl();
 }
 
-void ClassTemplatePartialSpecializationDecl::
-initTemplateArgsAsWritten(const TemplateArgumentListInfo &ArgInfos) {
-  assert(ArgsAsWritten == 0 && "ArgsAsWritten already set");
-  unsigned N = ArgInfos.size();
-  TemplateArgumentLoc *ClonedArgs
-    = new (getASTContext()) TemplateArgumentLoc[N];
-  for (unsigned I = 0; I != N; ++I)
-    ClonedArgs[I] = ArgInfos[I];
-  
-  ArgsAsWritten = ClonedArgs;
-  NumArgsAsWritten = N;
-}
-
 //===----------------------------------------------------------------------===//
 // FriendTemplateDecl Implementation
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=113743&r1=113742&r2=113743&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Sep 13 06:45:41 2010
@@ -1011,23 +1011,25 @@
                                     ClassTemplatePartialSpecializationDecl *D) {
   VisitClassTemplateSpecializationDecl(D);
 
-  D->initTemplateParameters(Reader.ReadTemplateParameterList(Record, Idx));
-  
-  TemplateArgumentListInfo ArgInfos;
+  ASTContext &C = *Reader.getContext();
+  D->TemplateParams = Reader.ReadTemplateParameterList(Record, Idx);
+
   unsigned NumArgs = Record[Idx++];
-  while (NumArgs--)
-    ArgInfos.addArgument(Reader.ReadTemplateArgumentLoc(Cursor, Record, Idx));
-  D->initTemplateArgsAsWritten(ArgInfos);
-  
-  D->setSequenceNumber(Record[Idx++]);
+  if (NumArgs) {
+    D->NumArgsAsWritten = NumArgs;
+    D->ArgsAsWritten = new (C) TemplateArgumentLoc[NumArgs];
+    for (unsigned i=0; i != NumArgs; ++i)
+      D->ArgsAsWritten[i] = Reader.ReadTemplateArgumentLoc(Cursor, Record, Idx);
+  }
+
+  D->SequenceNumber = Record[Idx++];
 
   // These are read/set from/to the first declaration.
   if (D->getPreviousDeclaration() == 0) {
-    D->setInstantiatedFromMember(
+    D->InstantiatedFromMember.setPointer(
         cast_or_null<ClassTemplatePartialSpecializationDecl>(
                                                 Reader.GetDecl(Record[Idx++])));
-    if (Record[Idx++])
-      D->setMemberSpecialization();
+    D->InstantiatedFromMember.setInt(Record[Idx++]);
   }
 }
 





More information about the cfe-commits mailing list