[PATCH] : Proper name lookup for namespaces

Hi,

The attached patch contains changes to support proper name lookup for namespaces.
It is mostly an overhaul of the IdentifierResolver:

-It exposes an iterator interface to get all decls through the scope chain:
  for (IdentifierResolver::iterator
       I = IdResolver.begin(II, CurContext), E = IdResolver.end(II); I != E; ++I)
    if ((*I)->getIdentifierNamespace() & NS)
      return *I;

-The semantic staff (checking IdentifierNamespace and Doug's checking for shadowed tags were moved out of IdentifierResolver and back into Sema. IdentifierResolver just gives an iterator for iterating over all reachable decls of an identifier.

-Fixes bug: http://llvm.org/bugs/show_bug.cgi?id=2275

-Argiris

cxx-namespaces-2.patch (30.6 KB)

Looks great to me, thanks Argiris!

-Chris

The attached patch contains changes to support proper name lookup for namespaces.
It is mostly an overhaul of the IdentifierResolver:

-It exposes an iterator interface to get all decls through the scope chain:
for (IdentifierResolver::iterator
     I = IdResolver.begin(II, CurContext), E = IdResolver.end(II); I != E; ++I)
  if ((*I)->getIdentifierNamespace() & NS)
    return *I;

-The semantic staff (checking IdentifierNamespace and Doug's checking for shadowed tags were moved out of IdentifierResolver and back into Sema. IdentifierResolver just gives an iterator for iterating over all reachable decls of an identifier.

-Fixes bug: http://llvm.org/bugs/show_bug.cgi?id=2275

Looks great to me, thanks Argiris!

Applied here:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080505/005668.html
with only a couple of changes:

-IdentifierResolver::AddShadowedDecl is passed a decl instead of an ctx_iterator
-Moved Sema::isDeclInScope to IdentifierResolver::isDeclInScope, so that it can use LookupContext class to check whether the decl belongs to the decl context (LookupContext, when encountering a EnumConstantDecl, uses the decl context that the EnumConstantDecl's EnumDecl belongs to).

-Argiris