FriendLoc(FriendLoc)
{}
+ FriendTemplateDecl(EmptyShell Empty)
+ : Decl(Decl::FriendTemplate, Empty),
+ NumParams(0),
+ Params(0)
+ {}
+
public:
static FriendTemplateDecl *Create(ASTContext &Context,
DeclContext *DC, SourceLocation Loc,
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.
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
= new (Context) FriendTemplateDecl(DC, L, NParams, Params, Friend, FLoc);
return Result;
}
+
+FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context,
+ EmptyShell Empty) {
+ return new (Context) FriendTemplateDecl(Empty);
+}
}
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) {
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(),
}
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) {