summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2011-04-24 16:28:21 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2011-04-24 16:28:21 +0000
commit010288f7c1b5eb4616ff6a648d4168b79a96a7b2 (patch)
treea89b6fa323ab1504e163f87b380279698aa9e6a2 /clang/lib/Serialization
parentfa1f370b7d208646a324a36ab1c4de324755af5d (diff)
downloadbcm5719-llvm-010288f7c1b5eb4616ff6a648d4168b79a96a7b2.tar.gz
bcm5719-llvm-010288f7c1b5eb4616ff6a648d4168b79a96a7b2.zip
Set the correct anonymous namespace (must be last reopening), and behave correctly in the presence of the ever-annoying linkage specifications.
llvm-svn: 130105
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp13
-rw-r--r--clang/lib/Serialization/ASTWriterDecl.cpp12
2 files changed, 16 insertions, 9 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 3d4e4cdd002..52eff1957dc 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1741,10 +1741,15 @@ void ASTDeclReader::UpdateDecl(Decl *D, const RecordData &Record) {
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(Record[Idx++]));
- if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D))
- TU->setAnonymousNamespace(Anon);
- else
- cast<NamespaceDecl>(D)->OrigOrAnonNamespace.setPointer(Anon);
+ // Guard against these being loaded out of original order. Don't use
+ // getNextNamespace(), since it tries to access the context and can't in
+ // the middle of deserialization.
+ if (!Anon->NextNamespace) {
+ if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D))
+ TU->setAnonymousNamespace(Anon);
+ else
+ cast<NamespaceDecl>(D)->OrigOrAnonNamespace.setPointer(Anon);
+ }
break;
}
}
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index db72be3f584..df83f2f6940 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -708,11 +708,13 @@ void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) {
}
}
- if (Writer.hasChain() && D->isOriginalNamespace() &&
- D->isAnonymousNamespace()) {
- // This is an original anonymous namespace. If its parent is in a previous
- // PCH (or is the TU), mark that parent for update.
- Decl *Parent = cast<Decl>(D->getParent()->getPrimaryContext());
+ if (Writer.hasChain() && D->isAnonymousNamespace() && !D->getNextNamespace()){
+ // This is a most recent reopening of the anonymous namespace. If its parent
+ // is in a previous PCH (or is the TU), mark that parent for update, because
+ // the original namespace always points to the latest re-opening of its
+ // anonymous namespace.
+ Decl *Parent = cast<Decl>(
+ D->getParent()->getRedeclContext()->getPrimaryContext());
if (Parent->getPCHLevel() > 0) {
ASTWriter::UpdateRecord &Record = Writer.DeclUpdates[Parent];
Record.push_back(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE);
OpenPOWER on IntegriCloud