]> granicus.if.org Git - clang/commitdiff
Implemented serialization of FunctionTypeProto.
authorTed Kremenek <kremenek@apple.com>
Sun, 28 Oct 2007 00:59:26 +0000 (00:59 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 28 Oct 2007 00:59:26 +0000 (00:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43419 91177308-0d34-0410-b5e6-96231b3b80d8

AST/TypeSerialization.cpp
include/clang/AST/Type.h

index efd6e763899b97111c5f1bb8a3ba9d15baf17a1b..83d8400d3f83da71a7c6eeff3df11bb7afb2f2c5 100644 (file)
@@ -172,3 +172,34 @@ FunctionTypeNoProto* FunctionTypeNoProto::Materialize(llvm::Deserializer& D) {
   T->ReadFunctionTypeInternal(D);
   return T;
 }
+
+void FunctionTypeProto::Emit(llvm::Serializer& S) const {
+  S.EmitInt(NumArgs);
+  EmitFunctionTypeInternal(S);
+  
+  for (arg_type_iterator i = arg_type_begin(), e = arg_type_end(); i!=e; ++i)
+    S.Emit(*i);    
+}
+
+FunctionTypeProto* FunctionTypeProto::Materialize(llvm::Deserializer& D) {
+  unsigned NumArgs = D.ReadInt();
+  
+  FunctionTypeProto *FTP = 
+  (FunctionTypeProto*)malloc(sizeof(FunctionTypeProto) + 
+                             NumArgs*sizeof(QualType));
+  
+  // Default construct.  Internal fields will be populated using
+  // deserialization.
+  new (FTP) FunctionTypeProto();
+  
+  FTP->NumArgs = NumArgs;
+  FTP->ReadFunctionTypeInternal(D);
+  
+  // Fill in the trailing argument array.
+  QualType *ArgInfo = reinterpret_cast<QualType *>(FTP+1);;
+
+  for (unsigned i = 0; i != NumArgs; ++i)
+    D.Read(ArgInfo[i]);
+  
+  return FTP;
+}
index c8ee202d1c05ff293c14d94929cf5f532e8da682..0bfc86f4d0733326227ae61401ba52b1e444ecf8 100644 (file)
@@ -790,6 +790,14 @@ public:
   static void Profile(llvm::FoldingSetNodeID &ID, QualType Result,
                       arg_type_iterator ArgTys, unsigned NumArgs,
                       bool isVariadic);
+  
+  void Emit(llvm::Serializer& S) const;
+  static FunctionTypeProto* Materialize(llvm::Deserializer& D);
+  
+protected:
+  // Used by deserialization.
+  FunctionTypeProto() 
+  : FunctionType(FunctionProto, QualType(), false, QualType()) {}
 };