Misc. serialization changes to ASTContext and Decls. Serialization
for ASTContext is still rapidly evolving.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43774 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/DeclSerialization.cpp b/AST/DeclSerialization.cpp
index 9ceb6ad..9600e30 100644
--- a/AST/DeclSerialization.cpp
+++ b/AST/DeclSerialization.cpp
@@ -49,8 +49,28 @@
}
Decl* Decl::Materialize(llvm::Deserializer& D) {
- assert (false && "FIXME: not implemented.");
- return NULL;
+ Kind k = static_cast<Kind>(D.ReadInt());
+
+ switch (k) {
+ default:
+ assert (false && "Not implemented.");
+ break;
+
+ case BlockVar:
+ return BlockVarDecl::Materialize(D);
+
+ case FileVar:
+ return FileVarDecl::Materialize(D);
+
+ case ParmVar:
+ return ParmVarDecl::Materialize(D);
+
+ case Function:
+ return FunctionDecl::Materialize(D);
+
+ case Typedef:
+ return TypedefDecl::Materialize(D);
+ }
}
void NamedDecl::InternalEmit(llvm::Serializer& S) const {
@@ -70,7 +90,7 @@
void ScopedDecl::InternalRead(llvm::Deserializer& D) {
NamedDecl::InternalRead(D);
D.ReadPtr(Next);
- NextDeclarator = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>());
+ NextDeclarator = cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>());
}
void ValueDecl::InternalEmit(llvm::Serializer& S) const {
@@ -93,7 +113,7 @@
void VarDecl::InternalRead(llvm::Deserializer& D) {
SClass = D.ReadInt();
objcDeclQualifier = static_cast<ObjcDeclQualifier>(D.ReadInt());
- VarDecl::InternalRead(D);
+ ValueDecl::InternalRead(D);
D.ReadOwnedPtr(Init);
}
@@ -172,14 +192,14 @@
void TypedefDecl::Emit(llvm::Serializer& S) const {
S.Emit(getLocation());
+ S.Emit(UnderlyingType);
InternalEmit(S);
- S.Emit(UnderlyingType);
}
TypedefDecl* TypedefDecl::Materialize(llvm::Deserializer& D) {
SourceLocation L = SourceLocation::ReadVal(D);
TypedefDecl* decl = new TypedefDecl(L,NULL,QualType(),NULL);
- decl->InternalRead(D);
D.Read(decl->UnderlyingType);
+ decl->InternalRead(D);
return decl;
}