[cfe-dev] PATCH: Overloaded function declarations in C++

Doug Gregor doug.gregor at gmail.com
Mon Sep 8 11:24:54 PDT 2008


On Mon, Sep 8, 2008 at 1:38 PM, Daniel Dunbar <daniel at zuster.org> wrote:
> I agree with Argiris that having an OverloadType and Decl is counterintuitive,
> although I think I understand the reason.

Does Argiris still agree with this? I think I may have converted him :)

> It sounds to me like a cleaner solution would be to change the interface with
> the parser to just be returning some richer (non-AST) type during name lookup
> which can encapsulate the information about overloads.

The problem is that OverloadedFunctionDecls can show up as children of
other AST nodes. For example, in

  void f(int); // #1
  void f(float); // #2
  (f)(1.5);

we'll end up building a
ParenExpr(DeclRefExpr(OverloadedFunctionDecl)). Keeping track of the
(f) without using AST nodes seems like it could get messy.

> Adding "fake" AST nodes
> to accomodate this seems outside the current design spirit and I think may
> spread complexity into places that don't deserve it.

I don't agree that it's a "fake" AST node. An overloaded function name
is a full-fledged concept in C++ semantic analysis. And even though
semantic analysis can remove these OverloadedFunctionDecl nodes now,
they'll need to be stored in the AST for templates (which must keep
track of overload sets explicitly, to be used again at instantiation
time).

  - Doug



More information about the cfe-dev mailing list