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 f0b179b..2a12cdf 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -1407,8 +1407,39 @@
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<ComplexType>::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<PointerType>::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);