[PCH] Make sure that all newly introduced visible decls in a DeclContext
coming from an AST file are registered for serialization.
A static data member instantiation of in a chained PCH could be missed
when serializing decls; the result was that when emitting the visible decls
map of its DeclContext, we would use a DeclID that was not actually emitted,
leading to crashes or hangs.
Fix this by making sure such decls are always registered for serialization.
Also introduce extra sanity checks to make sure we don't register new
declarations or types after we have serialized the types/decls block.
rdar://
11728990
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159550
91177308-0d34-0410-b5e6-
96231b3b80d8