summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-09 18:07:24 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-09 18:07:24 +0000
commit540fd8135ec592720caeb29ba5a0984b922515fe (patch)
tree10a0f8125ebb0af29739f6e597de156ee3f9836f /clang/lib
parentfa8df4837af316d93b3f815894f0c4d2bd071619 (diff)
downloadbcm5719-llvm-540fd8135ec592720caeb29ba5a0984b922515fe.tar.gz
bcm5719-llvm-540fd8135ec592720caeb29ba5a0984b922515fe.zip
When deserializing an anonymous namespace from a module, do not attach
the anonymous namespace to its parent. Semantically, this means that the anonymous namespaces defined in one module are distinct from the anonymous namespaces defined in another module. llvm-svn: 147782
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index f6c9bfaa572..6b8a72f807f 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -978,10 +978,12 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
mergeRedeclarable(D, Redecl);
if (Redecl.getFirstID() == ThisDeclID) {
- // FIXME: If there's already an anonymous namespace, do we merge it with
- // this one? Or do we, when loading modules, just forget about anonymous
- // namespace entirely?
- D->setAnonymousNamespace(ReadDeclAs<NamespaceDecl>(Record, Idx));
+ // Each module has its own anonymous namespace, which is disjoint from
+ // any other module's anonymous namespaces, so don't attach the anonymous
+ // namespace at all.
+ NamespaceDecl *Anon = ReadDeclAs<NamespaceDecl>(Record, Idx);
+ if (F.Kind != MK_Module)
+ D->setAnonymousNamespace(Anon);
} else {
// Link this namespace back to the first declaration, which has already
// been deserialized.
@@ -2484,10 +2486,16 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
NamespaceDecl *Anon
= Reader.ReadDeclAs<NamespaceDecl>(ModuleFile, Record, Idx);
- if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D))
- TU->setAnonymousNamespace(Anon);
- else
- cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
+
+ // Each module has its own anonymous namespace, which is disjoint from
+ // any other module's anonymous namespaces, so don't attach the anonymous
+ // namespace at all.
+ if (ModuleFile.Kind != MK_Module) {
+ if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D))
+ TU->setAnonymousNamespace(Anon);
+ else
+ cast<NamespaceDecl>(D)->setAnonymousNamespace(Anon);
+ }
break;
}
OpenPOWER on IntegriCloud