[cfe-dev] PATCH: C++ Function Overloading (v2)

Argiris Kirtzidis akyrtzi at gmail.com
Wed Oct 22 14:07:52 PDT 2008

Doug Gregor wrote:
> Generally, I like it, although I think we can do things a bit more
> efficiently. I'd like the DeclContext to own the
> OverloadedFunctionDecls, and cache them so that we aren't constantly
> re-creating them. This means that, for example, the first lookup of
> "f" for an overloaded function would find a number of FunctionDecl
> nodes, for which we'd create an OverloadedFunctionDecl. At that point,
> we should push the OverloadedFunctionDecl into the scope, so that it
> can be found and reused. This would be a lazy form of what the code is
> doing now.
> In the case of a template, where we need to store the
> OverloadedFunctionDecl for later use, I suggest that we have the code
> that needs to save the OverloadedFunctionDecl make a copy of it that
> will be owned by the DeclRefExpr or OverloadedFunctionDeclRefExpr, so
> that we're not wasting time creating and destroying
> OverloadedFunctionDecls that will only be used once before being
> destroyed.
> Another minor comment: we could probably eliminate
> OverloadedFunctionDeclRefExpr and instead use the lowest bit of the
> NamedDecl* in DeclRefExpr to record whether the DeclRefExpr owns the
> declaration or not.

Sounds great!

Thank you for your patience!
I may pester you later on about the possibility of using just the 
IdentifierInfo instead of a list of FunctionDecls for 
OverloadedFunctionDecl (which will save space for templates), but not 
until more name lookup rules (like the 'using' directive) are supported 
and its clear whether an IdentifierInfo is sufficient or not.


More information about the cfe-dev mailing list