From: Ted Kremenek Date: Tue, 6 Nov 2007 19:51:47 +0000 (+0000) Subject: Misc. serialization changes to ASTContext and Decls. Serialization X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ebc89f6cb08a5bea1795ecccf178237c12876c3;p=clang 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/ASTContext.cpp b/AST/ASTContext.cpp index 2a12cdf7a6..982ef05a06 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -1425,7 +1425,7 @@ void ASTContext::Emit(llvm::Serializer& S) const { } } - assert (PointerTypes.size() >= 1); + assert (PointerTypes.size() >= 1); S.EmitInt(PointerTypes.size() - 1); if (PointerTypes.size() > 1) { @@ -1450,13 +1450,13 @@ void ASTContext::Emit(llvm::Serializer& S) const { // FIXME: EmitSet(ObjcQualifiedInterfaceTypes,S); S.Emit(BuiltinVaListType); - S.Emit(ObjcIdType); - S.EmitPtr(IdStructType); - S.Emit(ObjcProtoType); - S.EmitPtr(ProtoStructType); - S.Emit(ObjcClassType); - S.EmitPtr(ClassStructType); - S.Emit(ObjcConstantStringType); +// FIXME: S.Emit(ObjcIdType); +// FIXME: S.EmitPtr(IdStructType); +// FIXME: S.Emit(ObjcProtoType); + // FIXME: S.EmitPtr(ProtoStructType); + // FIXME: S.Emit(ObjcClassType); +// FIXME: S.EmitPtr(ClassStructType); +// FIXME: S.Emit(ObjcConstantStringType); // FIXME: S.EmitOwnedPtr(CFConstantStringTypeDecl); } @@ -1505,13 +1505,13 @@ ASTContext* ASTContext::Materialize(llvm::Deserializer& D) { // ReadSet(A->ObjcQualifiedInterfaceTypes,D); D.Read(A->BuiltinVaListType); - D.Read(A->ObjcIdType); - D.ReadPtr(A->IdStructType); - D.Read(A->ObjcProtoType); - D.ReadPtr(A->ProtoStructType); - D.Read(A->ObjcClassType); - D.ReadPtr(A->ClassStructType); - D.Read(A->ObjcConstantStringType); +// FIXME: D.Read(A->ObjcIdType); +// FIXME: D.ReadPtr(A->IdStructType); +// FIXME: D.Read(A->ObjcProtoType); +// FIXME: D.ReadPtr(A->ProtoStructType); +// FIXME: D.Read(A->ObjcClassType); +// FIXME: D.ReadPtr(A->ClassStructType); +// FIXME: D.Read(A->ObjcConstantStringType); // FIXME: A->CFConstantStringTypeDecl = D.ReadOwnedPtr(); return A; diff --git a/AST/DeclSerialization.cpp b/AST/DeclSerialization.cpp index 9ceb6adaef..9600e30380 100644 --- a/AST/DeclSerialization.cpp +++ b/AST/DeclSerialization.cpp @@ -49,8 +49,28 @@ void Decl::Emit(llvm::Serializer& S) const { } Decl* Decl::Materialize(llvm::Deserializer& D) { - assert (false && "FIXME: not implemented."); - return NULL; + Kind k = static_cast(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::InternalEmit(llvm::Serializer& S) const { void ScopedDecl::InternalRead(llvm::Deserializer& D) { NamedDecl::InternalRead(D); D.ReadPtr(Next); - NextDeclarator = cast(D.ReadOwnedPtr()); + NextDeclarator = cast_or_null(D.ReadOwnedPtr()); } void ValueDecl::InternalEmit(llvm::Serializer& S) const { @@ -93,7 +113,7 @@ void VarDecl::InternalEmit(llvm::Serializer& S) const { void VarDecl::InternalRead(llvm::Deserializer& D) { SClass = D.ReadInt(); objcDeclQualifier = static_cast(D.ReadInt()); - VarDecl::InternalRead(D); + ValueDecl::InternalRead(D); D.ReadOwnedPtr(Init); } @@ -172,14 +192,14 @@ FunctionDecl* FunctionDecl::Materialize(llvm::Deserializer& D) { 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; }