aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-26 23:52:52 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-26 23:52:52 +0000
commita4cb4525cf4bf8f61299147f22ffc187ed1eac9e (patch)
tree084f51c05321e06d06ff28aaf43eb3dde2831afb
parent4d733d3288112667cfa3993424987b9ad9427f8f (diff)
More work on type serialization: added support for serializing BuiltinTypes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43414 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/TypeSerialization.cpp24
-rw-r--r--include/clang/AST/Type.h10
2 files changed, 33 insertions, 1 deletions
diff --git a/AST/TypeSerialization.cpp b/AST/TypeSerialization.cpp
index 1a685680d3..02b9f8803b 100644
--- a/AST/TypeSerialization.cpp
+++ b/AST/TypeSerialization.cpp
@@ -27,6 +27,16 @@ void QualType::Read(llvm::Deserializer& D) {
ThePtr |= D.ReadInt();
}
+void QualType::EmitOwned(llvm::Serializer& S) const {
+ S.EmitInt(getQualifiers());
+ S.EmitOwnedPtr(cast<BuiltinType>(getTypePtr()));
+}
+
+void QualType::ReadOwned(llvm::Deserializer& D) {
+ ThePtr = D.ReadInt();
+ ThePtr |= reinterpret_cast<uintptr_t>(D.ReadOwnedPtr<BuiltinType>());
+}
+
/* FIXME: Either remove this method or complete it.
void Type::Emit(llvm::Serializer& S) {
@@ -50,6 +60,18 @@ void Type::ReadTypeInternal(llvm::Deserializer& D) {
D.Read(CanonicalType);
}
+void BuiltinType::Emit(llvm::Serializer& S) const {
+ S.EmitInt(TypeKind);
+}
+
+BuiltinType* BuiltinType::Materialize(llvm::Deserializer& D) {
+ Kind k = static_cast<Kind>(D.ReadInt());
+ BuiltinType* T = new BuiltinType(k);
+ return T;
+}
+
+
+
void ComplexType::Emit(llvm::Serializer& S) const {
EmitTypeInternal(S);
S.Emit(ElementType);
@@ -106,7 +128,7 @@ void ConstantArrayType::Emit(llvm::Serializer& S) const {
}
ConstantArrayType* ConstantArrayType::Materialize(llvm::Deserializer& D) {
- // "Default" construct the array.
+ // "Default" construct the array type.
ConstantArrayType* T =
new ConstantArrayType(QualType(), QualType(), llvm::APInt(),
ArrayType::Normal, 0);
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 35eca6a435..b3832019ca 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -165,6 +165,12 @@ public:
/// exists, in place, within its containing object.
void Read(llvm::Deserializer& D);
+ /// EmitOwned - Serialize a QualType that owns the underlying Type*.
+ void EmitOwned(llvm::Serializer& S) const;
+
+ /// ReadOwned - Deserialize a QualType that owns the underlying Thpe*.
+ void ReadOwned(llvm::Deserializer& S);
+
private:
};
@@ -378,6 +384,7 @@ public:
static bool classof(const BuiltinType *) { return true; }
void Emit(llvm::Serializer& S) const;
+ static BuiltinType* Materialize(llvm::Deserializer& D);
};
/// ComplexType - C99 6.2.5p11 - Complex values. This supports the C99 complex
@@ -575,6 +582,9 @@ public:
return T->getTypeClass() == VariableArray;
}
static bool classof(const VariableArrayType *) { return true; }
+
+ // FIXME: Who owns VariableArrayType's? What are the semantics
+ // for serialization.
};
/// VectorType - GCC generic vector type. This type is created using