aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization/ASTWriterDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-12 00:15:20 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-12 00:15:20 +0000
commit6bf2b9fbd3e3adc38d4712de79aeaa81d651aa08 (patch)
treee5eaa8ad4655ff6ff9d0416e6eb55f791985db7e /lib/Serialization/ASTWriterDecl.cpp
parent63ab2c54dc641d4f3d28841aa86affbfdf805d32 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r--lib/Serialization/ASTWriterDecl.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp
index 45f8a32df0..98dad1c90e 100644
--- a/lib/Serialization/ASTWriterDecl.cpp
+++ b/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<Decl>(
D->getParent()->getRedeclContext()->getPrimaryContext());
- if (Parent->getPCHLevel() > 0) {
+ if (Parent->getPCHLevel() > 0 || isa<TranslationUnitDecl>(Parent)) {
ASTWriter::UpdateRecord &Record = Writer.DeclUpdates[Parent];
Record.push_back(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE);
Writer.AddDeclRef(D, Record);