]> granicus.if.org Git - clang/commitdiff
Read/write FriendTemplateDecl for PCH.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 22 Jul 2010 16:04:10 +0000 (16:04 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 22 Jul 2010 16:04:10 +0000 (16:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109113 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclTemplate.h
lib/AST/DeclTemplate.cpp
lib/Frontend/PCHReaderDecl.cpp
lib/Frontend/PCHWriterDecl.cpp

index f6421736cd92c4f5f616188f1cd8d1c8d9de7675..0b3727e50ca1504bed2807df7701a9f9d73c3eca 100644 (file)
@@ -1651,6 +1651,12 @@ private:
       FriendLoc(FriendLoc)
   {}
 
+  FriendTemplateDecl(EmptyShell Empty)
+    : Decl(Decl::FriendTemplate, Empty),
+      NumParams(0),
+      Params(0)
+  {}
+
 public:
   static FriendTemplateDecl *Create(ASTContext &Context,
                                     DeclContext *DC, SourceLocation Loc,
@@ -1659,6 +1665,8 @@ public:
                                     FriendUnion Friend,
                                     SourceLocation FriendLoc);
 
+  static FriendTemplateDecl *Create(ASTContext &Context, EmptyShell Empty);
+
   /// If this friend declaration names a templated type (or
   /// a dependent member type of a templated type), return that
   /// type;  otherwise return null.
@@ -1691,6 +1699,8 @@ public:
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == Decl::FriendTemplate; }
   static bool classof(const FriendTemplateDecl *D) { return true; }
+
+  friend class PCHDeclReader;
 };
 
 /// Implementation of inline functions that require the template declarations
index f308d71d5f695760e5db93a62fefe9d3d91a4238..7b44b4681e1fcf4cf00f4150148816f0589ed1b1 100644 (file)
@@ -631,3 +631,8 @@ FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context,
     = new (Context) FriendTemplateDecl(DC, L, NParams, Params, Friend, FLoc);
   return Result;
 }
+
+FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context,
+                                               EmptyShell Empty) {
+  return new (Context) FriendTemplateDecl(Empty);
+}
index 8ea75b727066c08f3cb61852ad5a4c5372f2bd93..d562d6f6212aa41d4f209a8df3bdaefe68e0434f 100644 (file)
@@ -853,7 +853,17 @@ void PCHDeclReader::VisitFriendDecl(FriendDecl *D) {
 }
 
 void PCHDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
-  assert(false && "cannot read FriendTemplateDecl");
+  VisitDecl(D);
+  unsigned NumParams = Record[Idx++];
+  D->NumParams = NumParams;
+  D->Params = new TemplateParameterList*[NumParams];
+  for (unsigned i = 0; i != NumParams; ++i)
+    D->Params[i] = Reader.ReadTemplateParameterList(Record, Idx);
+  if (Record[Idx++]) // HasFriendDecl
+    D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
+  else
+    D->Friend = Reader.GetTypeSourceInfo(Record, Idx);
+  D->FriendLoc = Reader.ReadSourceLocation(Record, Idx);
 }
 
 void PCHDeclReader::VisitTemplateDecl(TemplateDecl *D) {
@@ -1374,7 +1384,7 @@ Decl *PCHReader::ReadDeclRecord(unsigned Index) {
     D = FriendDecl::Create(*Context, Decl::EmptyShell());
     break;
   case pch::DECL_FRIEND_TEMPLATE:
-    assert(false && "cannot read FriendTemplateDecl");
+    D = FriendTemplateDecl::Create(*Context, Decl::EmptyShell());
     break;
   case pch::DECL_CLASS_TEMPLATE:
     D = ClassTemplateDecl::Create(*Context, 0, SourceLocation(),
index eb7c52ae95b3aa77a82ef0cb0e62f4c8ae54a8c6..122bd3dea1a750c9166dcea555c1ead95bbe74ea 100644 (file)
@@ -818,7 +818,17 @@ void PCHDeclWriter::VisitFriendDecl(FriendDecl *D) {
 }
 
 void PCHDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
-  assert(false && "cannot write FriendTemplateDecl");
+  VisitDecl(D);
+  Record.push_back(D->getNumTemplateParameters());
+  for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
+    Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record);
+  Record.push_back(D->getFriendDecl() != 0);
+  if (D->getFriendDecl())
+    Writer.AddDeclRef(D->getFriendDecl(), Record);
+  else
+    Writer.AddTypeSourceInfo(D->getFriendType(), Record);
+  Writer.AddSourceLocation(D->getFriendLoc(), Record);
+  Code = pch::DECL_FRIEND_TEMPLATE;
 }
 
 void PCHDeclWriter::VisitTemplateDecl(TemplateDecl *D) {