From: Ted Kremenek Date: Mon, 5 Nov 2007 20:49:23 +0000 (+0000) Subject: For serialization of ASTContext, added special-casing of serialization X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8712eb9c712fcb88c626167e3b89d81341a58d1;p=clang For serialization of ASTContext, added special-casing of serialization of type sets when emitting complex types and pointer types that are also considered builtins. These types are automatically created in the ctor of ASTContext, and thus should not be serialized (was producing an error during deserialization). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43733 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index f0b179bf39..2a12cdf7a6 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -1407,8 +1407,39 @@ void ASTContext::Emit(llvm::Serializer& S) const { EmitBuiltin(S,VoidPtrTy); // Emit the remaining types. - EmitSet(ComplexTypes, S); - EmitSet(PointerTypes, S); + + assert (ComplexTypes.size() >= 3); + S.EmitInt(ComplexTypes.size() - 3); + + if (ComplexTypes.size() > 3) { + + for (llvm::FoldingSet::const_iterator + I=ComplexTypes.begin(), E=ComplexTypes.end(); I!=E; ++I) { + + const ComplexType* T = &*I; + + if (T != FloatComplexTy.getTypePtr() && + T != DoubleComplexTy.getTypePtr() && + T != LongDoubleComplexTy.getTypePtr()) + S.EmitOwnedPtr(&*I); + } + } + + assert (PointerTypes.size() >= 1); + S.EmitInt(PointerTypes.size() - 1); + + if (PointerTypes.size() > 1) { + + for (llvm::FoldingSet::const_iterator + I=PointerTypes.begin(), E=PointerTypes.end(); I!=E; ++I) { + + const PointerType* T = &*I; + + if (T != VoidPtrTy.getTypePtr()) + S.EmitOwnedPtr(&*I); + } + } + EmitSet(ReferenceTypes, S); EmitSet(ConstantArrayTypes, S); EmitSet(IncompleteVariableArrayTypes, S);