[cfe-dev] PATCH: Cleanup function redeclaration representations

Doug Gregor doug.gregor at gmail.com
Thu Apr 24 08:48:53 PDT 2008


On Thu, Apr 24, 2008 at 11:21 AM, Argiris Kirtzidis <akyrtzi at gmail.com> wrote:
> > These are questions that apply to either case of merging:
> >
> >  typedef int MyFlags;
> >  void f(MyFlags flags = 0); // #1
> >  void f(int x); // #2
> >
> >
> > What parts of the declaration at #1 will go into the FunctionDecl for
> > #2? Additionally: when information gets merged into #2, is that same
> > information that was in the FunctionDecl for #2 lost? (e.g., the
> > parameter name "x" it used?)
> >
>
>  The point here is, given a decl #1 and a redecl #2, is there an advantage
> in merging #1 -> #2, instead of #2 -> #1 ?

Merging #1 into #2 means that both #1 and #2 contain all of the
information that its corresponding declarations contains. #1 contains
all of the information about the first declaration of "f", including
the exact type (with typedefs and such), parameter names, and which
default arguments were present. #2 contains all of the information
about the second declaration, its exact parameter types, parameter
names, etc., which includes the merging of default arguments.
(Semantically, the merged default arguments become a part of the
declaration at #2).

So, merging #1 into #2 this gives us very precise information about
each of the declaration. I don't see how we can keep all of that
information when merging #2 into #1, unless we do something like the
"swap" trick that I'm already doing. Just merging #2 into #1 directly
means that we'll lose the source information that was in #1. Or
perhaps you are thinking of a different way of doing this merge?

  - Doug



More information about the cfe-dev mailing list