diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-03 23:26:26 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-03 23:26:26 +0000 |
commit | 7a537404f039d4b7d063bbdc3c8c924be977dff2 (patch) | |
tree | fb86628ee53655e5f02c3dd8d7f731e0b5a5af7e /lib/Sema/SemaLookup.cpp | |
parent | 3edd5a99332dd8ec94a545476dc3c9ed50dec78f (diff) |
Test "merging" of typedef types across distinct modules. At present,
the AST reader doesn't actually perform a merge, because name lookup
knows how to merge identical typedefs together.
As part of this, teach C/Objective-C name lookup to return multiple
results in all cases, rather than first digging through the attributes
to see if the value is overloadable. This way, we'll catch ambiguous
lookups in C/Objective-C.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147498 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 4f53487dcd..f836a077b6 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1177,30 +1177,31 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { R.addDecl(D); - if ((*I)->getAttr<OverloadableAttr>()) { - // If this declaration has the "overloadable" attribute, we - // might have a set of overloaded functions. - - // Figure out what scope the identifier is in. - while (!(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; - - D = getVisibleDecl(*LastI); - if (D) - R.addDecl(D); - } + // Check whether there are any other declarations with the same name + // and in the same scope. + + // 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 = getVisibleDecl(*LastI); + if (D) + R.addDecl(D); } R.resolveKind(); - return true; } } else { |