diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-09 17:38:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-09 17:38:47 +0000 |
commit | 9b47f941336474a054ccc5caf3ae430eb12343d9 (patch) | |
tree | f2e5c043c3ee77b55fad731bb906f29e297d7836 /clang/lib/Serialization/ASTReaderDecl.cpp | |
parent | f7fe24f40a3600bb961cbb5aeb7a5eb440b1a3fc (diff) | |
download | bcm5719-llvm-9b47f941336474a054ccc5caf3ae430eb12343d9.tar.gz bcm5719-llvm-9b47f941336474a054ccc5caf3ae430eb12343d9.zip |
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.
llvm-svn: 147780
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index ffd768a94d2..f6c9bfaa572 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/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); } |