summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-11-14 22:51:02 +0000
committerTed Kremenek <kremenek@apple.com>2007-11-14 22:51:02 +0000
commit83b75f5ee8e55d9cd3fbe1c1e887766201c70d1b (patch)
treee71508256d19477e6af3c6cc8f8baf8911252fba /clang
parentc6225532c34ab872ed02d68ed5b4c43c6ea92509 (diff)
downloadbcm5719-llvm-83b75f5ee8e55d9cd3fbe1c1e887766201c70d1b.tar.gz
bcm5719-llvm-83b75f5ee8e55d9cd3fbe1c1e887766201c70d1b.zip
Added QualType::ReadBackpatch to allow QualType initialization with
backpatching. This original was available, but then we removed it. It is back again to help with deserialization of FieldDecls. Because FieldDecls are currently owned by RecordDecls, which are owned by a TagType, the type of the FieldDecl may not be deserialized prior to deserializing the FieldDecl. Thus backpatching solves the problem of constructing a FieldDecl that references a type that has not yet been deserialized. Simplified serialization of TagType to not require passing in the SerializedPtrID. Registration of the materialized type object is done after the CreateImpl method returns (as with other types). llvm-svn: 44143
Diffstat (limited to 'clang')
-rw-r--r--clang/AST/DeclSerialization.cpp4
-rw-r--r--clang/AST/TypeSerialization.cpp14
-rw-r--r--clang/include/clang/AST/Type.h8
3 files changed, 15 insertions, 11 deletions
diff --git a/clang/AST/DeclSerialization.cpp b/clang/AST/DeclSerialization.cpp
index 555c33edf68..208e81ca0f9 100644
--- a/clang/AST/DeclSerialization.cpp
+++ b/clang/AST/DeclSerialization.cpp
@@ -295,8 +295,8 @@ void FieldDecl::EmitImpl(Serializer& S) const {
}
FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
- QualType DeclType = QualType::ReadVal(D);
- FieldDecl* decl = new FieldDecl(SourceLocation(),NULL,DeclType);
+ FieldDecl* decl = new FieldDecl(SourceLocation(),NULL,QualType());
+ decl->DeclType.ReadBackpatch(D);
decl->ReadInRec(D);
decl->BitWidth = D.ReadOwnedPtr<Expr>();
return decl;
diff --git a/clang/AST/TypeSerialization.cpp b/clang/AST/TypeSerialization.cpp
index 08d3194f195..e46abe4df1d 100644
--- a/clang/AST/TypeSerialization.cpp
+++ b/clang/AST/TypeSerialization.cpp
@@ -35,6 +35,11 @@ QualType QualType::ReadVal(Deserializer& D) {
return Q;
}
+void QualType::ReadBackpatch(Deserializer& D) {
+ D.ReadUIntPtr(ThePtr,true);
+ ThePtr |= D.ReadInt();
+}
+
//===----------------------------------------------------------------------===//
// Type Serialization: Dispatch code to handle specific types.
//===----------------------------------------------------------------------===//
@@ -87,7 +92,7 @@ void Type::Create(ASTContext& Context, unsigned i, Deserializer& D) {
break;
case Type::Tagged:
- TagType::CreateImpl(Context,PtrID,D);
+ D.RegisterPtr(PtrID,TagType::CreateImpl(Context,D));
break;
case Type::TypeName:
@@ -193,18 +198,13 @@ void TagType::EmitImpl(Serializer& S) const {
S.EmitOwnedPtr(getDecl());
}
-Type* TagType::CreateImpl(ASTContext& Context, SerializedPtrID& PtrID,
- Deserializer& D) {
-
+Type* TagType::CreateImpl(ASTContext& Context, Deserializer& D) {
std::vector<Type*>& Types =
const_cast<std::vector<Type*>&>(Context.getTypes());
TagType* T = new TagType(NULL,QualType());
Types.push_back(T);
- // Forward register the type pointer before deserializing the decl.
- D.RegisterPtr(PtrID,T);
-
// Deserialize the decl.
T->decl = cast<TagDecl>(D.ReadOwnedPtr<Decl>());
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index c42a1b00c9c..d6dc5f7d6bc 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -32,6 +32,7 @@ namespace clang {
class TagDecl;
class RecordDecl;
class EnumDecl;
+ class FieldDecl;
class ObjcInterfaceDecl;
class ObjcProtocolDecl;
class ObjcMethodDecl;
@@ -161,6 +162,10 @@ public:
/// Read - Deserialize a QualType from Bitcode.
static QualType ReadVal(llvm::Deserializer& D);
+
+private:
+ void ReadBackpatch(llvm::Deserializer& D);
+ friend class FieldDecl;
};
} // end clang.
@@ -888,8 +893,7 @@ public:
protected:
virtual void EmitImpl(llvm::Serializer& S) const;
- static Type* CreateImpl(ASTContext& Context, llvm::SerializedPtrID& PtrID,
- llvm::Deserializer& D);
+ static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D);
friend class Type;
};
OpenPOWER on IntegriCloud