Introduce a DeclsToRewrite field in ASTWrite, used for collecting the decls that will be replaced in the chained PCH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117238 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h
index 71d20dd..d6b1467 100644
--- a/include/clang/Serialization/ASTWriter.h
+++ b/include/clang/Serialization/ASTWriter.h
@@ -223,6 +223,10 @@
/// to this set, so that we can write out lexical content updates for it.
llvm::SmallPtrSet<const NamespaceDecl *, 16> UpdatedNamespaces;
+ typedef llvm::SmallPtrSet<const Decl *, 16> DeclsToRewriteTy;
+ /// \brief Decls that will be replaced in the current dependent AST file.
+ DeclsToRewriteTy DeclsToRewrite;
+
/// \brief Decls that have been replaced in the current dependent AST file.
///
/// When a decl changes fundamentally after being deserialized (this shouldn't
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 7636f02..c6df2dd 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -2410,6 +2410,10 @@
else
WriteDecl(Context, DOT.getDecl());
}
+ for (DeclsToRewriteTy::iterator
+ I = DeclsToRewrite.begin(), E = DeclsToRewrite.end(); I != E; ++I) {
+ WriteDecl(Context, const_cast<Decl*>(*I));
+ }
Stream.ExitBlock();
WritePreprocessor(PP);
@@ -2720,6 +2724,9 @@
const Decl *D = I->first;
UpdateRecord &URec = I->second;
+ if (DeclsToRewrite.count(D))
+ continue; // The decl will be written completely,no need to store updates.
+
uint64_t Offset = Stream.GetCurrentBitNo();
Stream.EmitRecord(DECL_UPDATES, URec);