diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-01-04 16:44:10 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-01-04 16:44:10 +0000 |
| commit | 9b7b39116ea07aea979ea49c4ec32ded85a5019f (patch) | |
| tree | afa05b12dbf5b7ae28209d5f9e1c0c797de01a97 /clang/lib/Sema/SemaLookup.cpp | |
| parent | f368486f4c09e7de29f094c793a666b35f806790 (diff) | |
| download | bcm5719-llvm-9b7b39116ea07aea979ea49c4ec32ded85a5019f.tar.gz bcm5719-llvm-9b7b39116ea07aea979ea49c4ec32ded85a5019f.zip | |
Implement declaration merging for typedefs loaded from disjoint
modules, so long as the typedefs refer to the same underlying
type. This ensures that the typedefs end up in the same redeclaration
chain.
To test this, fix name lookup for C/Objective-C to properly deal with
multiple declarations with the same name in the same scope.
llvm-svn: 147533
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 48ae1b970dd..ae950ff27aa 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1179,29 +1179,28 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { // Check whether there are any other declarations with the same name // and in the same scope. + if (I != IEnd) { + DeclContext *DC = (*I)->getDeclContext()->getRedeclContext(); + IdentifierResolver::iterator LastI = I; + for (++LastI; LastI != IEnd; ++LastI) { + DeclContext *LastDC + = (*LastI)->getDeclContext()->getRedeclContext(); + if (!(*LastI)->isInIdentifierNamespace(IDNS)) + continue; + + if (!LastDC->Equals(DC)) + break; + + if (!LastDC->isFileContext() && !S->isDeclScope(*LastI)) + break; + + D = R.isForRedeclaration()? *LastI : getVisibleDecl(*LastI); + if (D) + R.addDecl(D); + } - // Figure out what scope the identifier is in. - while (S->getParent() && - (!(S->getFlags() & Scope::DeclScope) || - !S->isDeclScope(*I))) - S = S->getParent(); - - // Find the last declaration in this scope (with the same - // name, naturally). - IdentifierResolver::iterator LastI = I; - for (++LastI; LastI != IEnd; ++LastI) { - if (!S->isDeclScope(*LastI)) - break; - - if (!(*LastI)->isInIdentifierNamespace(IDNS)) - continue; - - D = R.isForRedeclaration()? *LastI : getVisibleDecl(*LastI); - if (D) - R.addDecl(D); + R.resolveKind(); } - - R.resolveKind(); return true; } } else { |

