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 | da795b45f47df61a1b5a491e8d4ea078cf2a217b (patch) | |
tree | 72522014c932cf89f5ab08d515f03ad14f49ea3c /lib/Sema/SemaLookup.cpp | |
parent | b3453a810407cd8d7f526c6faabe9a4c9f0a6f67 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147533 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 48ae1b970d..ae950ff27a 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/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 { |