forked from OSchip/llvm-project
Read/write the identifier namespace in PCH for decls that may modify it.
We can now use a PCH'ed <map>. llvm-svn: 107617
This commit is contained in:
parent
927d8e06c1
commit
a95d019150
|
@ -1599,6 +1599,9 @@ public:
|
|||
static FunctionDecl *castFromDeclContext(const DeclContext *DC) {
|
||||
return static_cast<FunctionDecl *>(const_cast<DeclContext*>(DC));
|
||||
}
|
||||
|
||||
friend class PCHDeclReader;
|
||||
friend class PCHDeclWriter;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1960,6 +1963,9 @@ public:
|
|||
static TagDecl *castFromDeclContext(const DeclContext *DC) {
|
||||
return static_cast<TagDecl *>(const_cast<DeclContext*>(DC));
|
||||
}
|
||||
|
||||
friend class PCHDeclReader;
|
||||
friend class PCHDeclWriter;
|
||||
};
|
||||
|
||||
/// EnumDecl - Represents an enum. As an extension, we allow forward-declared
|
||||
|
|
|
@ -629,6 +629,9 @@ public:
|
|||
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
|
||||
static bool classof(const FunctionTemplateDecl *D) { return true; }
|
||||
static bool classofKind(Kind K) { return K == FunctionTemplate; }
|
||||
|
||||
friend class PCHDeclReader;
|
||||
friend class PCHDeclWriter;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -1527,6 +1530,9 @@ public:
|
|||
static bool classofKind(Kind K) { return K == ClassTemplate; }
|
||||
|
||||
virtual void Destroy(ASTContext& C);
|
||||
|
||||
friend class PCHDeclReader;
|
||||
friend class PCHDeclWriter;
|
||||
};
|
||||
|
||||
/// Declaration of a friend template. For example:
|
||||
|
|
|
@ -159,6 +159,7 @@ void PCHDeclReader::VisitTypedefDecl(TypedefDecl *TD) {
|
|||
|
||||
void PCHDeclReader::VisitTagDecl(TagDecl *TD) {
|
||||
VisitTypeDecl(TD);
|
||||
TD->IdentifierNamespace = Record[Idx++];
|
||||
TD->setPreviousDeclaration(
|
||||
cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
|
||||
|
@ -210,6 +211,7 @@ void PCHDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) {
|
|||
void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
||||
VisitDeclaratorDecl(FD);
|
||||
|
||||
FD->IdentifierNamespace = Record[Idx++];
|
||||
switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
|
||||
default: assert(false && "Unhandled TemplatedKind!");
|
||||
break;
|
||||
|
@ -282,7 +284,9 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
|||
// FunctionDecl's body is handled last at PCHReaderDecl::Visit,
|
||||
// after everything else is read.
|
||||
|
||||
FD->setPreviousDeclaration(
|
||||
// Avoid side effects and invariant checking of FunctionDecl's
|
||||
// setPreviousDeclaration.
|
||||
FD->redeclarable_base::setPreviousDeclaration(
|
||||
cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]);
|
||||
FD->setStorageClassAsWritten((FunctionDecl::StorageClass)Record[Idx++]);
|
||||
|
@ -304,11 +308,6 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
|||
for (unsigned I = 0; I != NumParams; ++I)
|
||||
Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
FD->setParams(Params.data(), NumParams);
|
||||
|
||||
// FIXME: order this properly w.r.t. friendness
|
||||
// FIXME: this same thing needs to happen for function templates
|
||||
if (FD->isOverloadedOperator() && !FD->getDeclContext()->isRecord())
|
||||
FD->setNonMemberOperator();
|
||||
}
|
||||
|
||||
void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
|
||||
|
@ -822,6 +821,7 @@ void PCHDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) {
|
|||
}
|
||||
|
||||
void PCHDeclReader::VisitFriendDecl(FriendDecl *D) {
|
||||
VisitDecl(D);
|
||||
if (Record[Idx++])
|
||||
D->Friend = Reader.GetTypeSourceInfo(Record, Idx);
|
||||
else
|
||||
|
@ -846,6 +846,7 @@ void PCHDeclReader::VisitTemplateDecl(TemplateDecl *D) {
|
|||
void PCHDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
|
||||
VisitTemplateDecl(D);
|
||||
|
||||
D->IdentifierNamespace = Record[Idx++];
|
||||
ClassTemplateDecl *PrevDecl =
|
||||
cast_or_null<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
||||
D->setPreviousDeclaration(PrevDecl);
|
||||
|
@ -952,6 +953,7 @@ void PCHDeclReader::VisitClassTemplatePartialSpecializationDecl(
|
|||
void PCHDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
|
||||
VisitTemplateDecl(D);
|
||||
|
||||
D->IdentifierNamespace = Record[Idx++];
|
||||
FunctionTemplateDecl *PrevDecl =
|
||||
cast_or_null<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
||||
D->setPreviousDeclaration(PrevDecl);
|
||||
|
|
|
@ -161,6 +161,7 @@ void PCHDeclWriter::VisitTypedefDecl(TypedefDecl *D) {
|
|||
|
||||
void PCHDeclWriter::VisitTagDecl(TagDecl *D) {
|
||||
VisitTypeDecl(D);
|
||||
Record.push_back(D->getIdentifierNamespace());
|
||||
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
|
||||
Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding
|
||||
Record.push_back(D->isDefinition());
|
||||
|
@ -212,6 +213,7 @@ void PCHDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {
|
|||
void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
|
||||
VisitDeclaratorDecl(D);
|
||||
|
||||
Record.push_back(D->getIdentifierNamespace());
|
||||
Record.push_back(D->getTemplatedKind());
|
||||
switch (D->getTemplatedKind()) {
|
||||
default: assert(false && "Unhandled TemplatedKind!");
|
||||
|
@ -787,6 +789,7 @@ void PCHDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) {
|
|||
}
|
||||
|
||||
void PCHDeclWriter::VisitFriendDecl(FriendDecl *D) {
|
||||
VisitDecl(D);
|
||||
Record.push_back(D->Friend.is<TypeSourceInfo*>());
|
||||
if (D->Friend.is<TypeSourceInfo*>())
|
||||
Writer.AddTypeSourceInfo(D->Friend.get<TypeSourceInfo*>(), Record);
|
||||
|
@ -811,6 +814,7 @@ void PCHDeclWriter::VisitTemplateDecl(TemplateDecl *D) {
|
|||
void PCHDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
|
||||
VisitTemplateDecl(D);
|
||||
|
||||
Record.push_back(D->getIdentifierNamespace());
|
||||
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
|
||||
if (D->getPreviousDeclaration() == 0) {
|
||||
// This ClassTemplateDecl owns the CommonPtr; write it.
|
||||
|
@ -899,6 +903,7 @@ void PCHDeclWriter::VisitClassTemplatePartialSpecializationDecl(
|
|||
void PCHDeclWriter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
|
||||
VisitTemplateDecl(D);
|
||||
|
||||
Record.push_back(D->getIdentifierNamespace());
|
||||
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
|
||||
if (D->getPreviousDeclaration() == 0) {
|
||||
// This FunctionTemplateDecl owns the CommonPtr; write it.
|
||||
|
|
Loading…
Reference in New Issue