aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-28 00:59:26 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-28 00:59:26 +0000
commit4340bfa9f442b450b8d81081fb463b03a0096230 (patch)
tree7b8d95da686afb35ebdcc5fd69b82f94a65f072e
parente81e24c84bae6d5a999d9e34a21c4ec73f91d37e (diff)
Implemented serialization of FunctionTypeProto.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43419 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/TypeSerialization.cpp31
-rw-r--r--include/clang/AST/Type.h8
2 files changed, 39 insertions, 0 deletions
diff --git a/AST/TypeSerialization.cpp b/AST/TypeSerialization.cpp
index efd6e76389..83d8400d3f 100644
--- a/AST/TypeSerialization.cpp
+++ b/AST/TypeSerialization.cpp
@@ -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;
+}
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index c8ee202d1c..0bfc86f4d0 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -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()) {}
};