Read/write FriendTemplateDecl for PCH.

llvm-svn: 109113
This commit is contained in:
Argyrios Kyrtzidis 2010-07-22 16:04:10 +00:00
parent 47cd7a91f4
commit 165b58181f
4 changed files with 38 additions and 3 deletions

View 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

View 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);
}

View 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(),

View 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) {