[cfe-commits] r43414 - in /cfe/trunk: AST/TypeSerialization.cpp include/clang/AST/Type.h

Ted Kremenek kremenek at apple.com
Fri Oct 26 16:52:52 PDT 2007


Author: kremenek
Date: Fri Oct 26 18:52:52 2007
New Revision: 43414

URL: http://llvm.org/viewvc/llvm-project?rev=43414&view=rev
Log:
More work on type serialization: added support for serializing BuiltinTypes.

Modified:
    cfe/trunk/AST/TypeSerialization.cpp
    cfe/trunk/include/clang/AST/Type.h

Modified: cfe/trunk/AST/TypeSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/TypeSerialization.cpp?rev=43414&r1=43413&r2=43414&view=diff

==============================================================================
--- cfe/trunk/AST/TypeSerialization.cpp (original)
+++ cfe/trunk/AST/TypeSerialization.cpp Fri Oct 26 18:52:52 2007
@@ -27,6 +27,16 @@
   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 @@
   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 @@
 }
 
 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);

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=43414&r1=43413&r2=43414&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Oct 26 18:52:52 2007
@@ -165,6 +165,12 @@
   ///  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 @@
   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 @@
     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





More information about the cfe-commits mailing list