aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-09 17:38:47 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-09 17:38:47 +0000
commit0fdc09fe680787b855cf20183c4bd3b83f2c907f (patch)
treed0b4b5a3084439d53d910b4536bcc6f9c10e0522 /lib/Serialization
parentc6c8e0ec96bb64f1b9f543d7c8317c6090f80a30 (diff)
Implement merging of namespace-scope declarations across modules, so
that we can merge, for example, two occurrences of namespace N { void f(); } in two disjoint modules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index ffd768a94d..f6c9bfaa57 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -1741,14 +1741,14 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
}
ASTDeclReader::FindExistingResult::~FindExistingResult() {
- if (!AddResult)
+ if (!AddResult || Existing)
return;
DeclContext *DC = New->getDeclContext()->getRedeclContext();
if (DC->isTranslationUnit() && Reader.SemaObj) {
- if (!Existing) {
- Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName());
- }
+ Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName());
+ } else if (DC->isNamespace()) {
+ DC->addDecl(New);
}
}
@@ -1775,7 +1775,13 @@ ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) {
}
}
- // FIXME: Search in the DeclContext.
+ if (DC->isNamespace()) {
+ for (DeclContext::lookup_result R = DC->lookup(Name);
+ R.first != R.second; ++R.first) {
+ if (isSameEntity(*R.first, D))
+ return FindExistingResult(Reader, D, *R.first);
+ }
+ }
return FindExistingResult(Reader, D, /*Existing=*/0);
}