[cfe-dev] Qualified and unqualified name lookup and IdResolver
Sebastian Redl
sebastian.redl at getdesigned.at
Thu Dec 4 23:57:07 PST 2008
On Thu, 4 Dec 2008 17:30:10 -0800, Douglas Gregor <dgregor at apple.com>
wrote:
> The attached patch changes how we perform both qualified and
> unqualified name lookup in Clang. It represents a significant
> departure from the approach currently implemented in Clang, but I
> believe it will have performance and maintainability benefits in the
> future.
>
> I propose---and this patch implements---an alternative solution that
> returns the chain of declarations back to a chain of declarations that
> occur within the lexical scope of the program. For our function N2::f,
> the chain for "x" would contain only #1, which is the only "x" within
> the lexical scope. Essentially, when names get introduced into a scope
> via a declaration, they are added to the declaration chain for their
> name; when that scope is destroyed those names are removed from the
> declaration chain. That way, the declaration chains only contain
> declarations that can actually be found by unqualified name lookup,
> and are no deeper than the nesting of lexical scopes.
>
> For qualified name lookup, each DeclContext has the ability to perform
> a lookup into the declarations it contains. For example, to find N::x,
> we would ask the DeclContext represented by N whether it has a name
> "x" in it. The lookup is performed in an efficient data structure: for
> < 6 declarations in the DeclContext, it's an array; for more
> declarations, it's a hash table.
>
Haven't looked at the patch yet, but I like the concept very much.
Sebastian
More information about the cfe-dev
mailing list