From dab42432d78320dfead646e6b4a6aa5bde342f5f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 12 Aug 2011 00:15:20 +0000 Subject: In the serialized AST format, make the translation unit a "predefined" declaration that never actually gets serialized. Instead, serialize the various kinds of update records (lexical decls, visible decls, the addition of an anonymous namespace) for the translation unit, even if we're not chaining. This way, we won't have to deal with multiple loaded translation unit declarations. llvm-svn: 137395 --- clang/lib/Serialization/ASTWriterDecl.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp') diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 45f8a32df04..98dad1c90ee 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -157,9 +157,7 @@ void ASTDeclWriter::VisitDecl(Decl *D) { } void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { - VisitDecl(D); - Writer.AddDeclRef(D->getAnonymousNamespace(), Record); - Code = serialization::DECL_TRANSLATION_UNIT; + llvm_unreachable("Translation units aren't directly serialized"); } void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) { @@ -819,7 +817,7 @@ void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) { // anonymous namespace. Decl *Parent = cast( D->getParent()->getRedeclContext()->getPrimaryContext()); - if (Parent->getPCHLevel() > 0) { + if (Parent->getPCHLevel() > 0 || isa(Parent)) { ASTWriter::UpdateRecord &Record = Writer.DeclUpdates[Parent]; Record.push_back(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE); Writer.AddDeclRef(D, Record); -- cgit v1.2.3