[cfe-dev] PATCH: Overloaded function declarations in C++
doug.gregor at gmail.com
Mon Sep 8 12:45:20 PDT 2008
On Mon, Sep 8, 2008 at 3:36 PM, Daniel Dunbar <daniel at zuster.org> wrote:
> The other part that seemed fake was that they are not a "decl" in the sense of
> actually defining anything or existing per se in the source. Are they
> a "Decl" for
> any reason other than shoehorning into the types the Parser expects? And if so,
> do they need to be a ValueDecl?
I think they are declarations in the same sense that using
declarations are declarations: while they don't necessarily introduce
a new entity with a name, they do declare a binding for a particular
name to one or more entities.
OverloadedFunctionDecls are ValueDecls because DeclRefExpr needs to be
able to refer to them. Plus, OverloadedFunctionDecls are "values" just
like other functions... the only difference being that we don't know
which value we're referring to just yet.
> Aside from its use in the decl, I don't really see why OverloadType is needed...
Well, because OverloadedFunctionDecl is a ValueDecl, it needs to have
a type. One might consider giving it a "null" type (QualType()), but
the introduction of OverloadType is mainly defensive: if we end up
getting an OverloadedFunctionDecl somewhere we don't expect and the
result is a type error, we'll get a friendly <overloaded function
type> type name rather than a crash.
I expect that, later down the road, we'll see other placeholder types
like this, such as a DependentType for dependent types with templates.
More information about the cfe-dev