[cfe-dev] PATCH: Cleanup function redeclaration representations

Doug Gregor doug.gregor at gmail.com
Sun May 4 17:35:59 PDT 2008


On Sun, May 4, 2008 at 6:25 PM, Chris Lattner <clattner at apple.com> wrote:
>  On May 4, 2008, at 5:10 PM, Doug Gregor wrote:
> > , if that also implies that
> > everything in the AST will refer to the aggregate version (except, of
> > course, the list of redeclarations). Can we do this without always
> > having an aggregate node? I'm not sure we can, because we run into
> > trouble like this:
> >
> >  void foo(int); // #1: no aggregate
> >  void bar(int i) { foo(i); }
> >  void foo(int x) { ... } // #2: now we create the aggregate, but
> > bar() points at #2.
> >
> > This is why I ended up with the swapping mess in the first place. Argh!
> >
>
>  I don't think there is a really easy way to do that.  Is there any harm in
> having the call to foo in bar pointing to the old decl?  What client would
> be affected by this, sema wouldn't be, right?

The harm in having bar's call to foo point to the old decl is that it
forces the D->getCanonicalDecl() convention onto every use of the AST
that is interested in getting at the semantic interface, including all
of Sema. That kind of interface convention invites a lot of
programming errors; we've already seen some confusion with canonical
types, but there at least people expect to have a different
representation when typedefs are preserved.

  - Doug



More information about the cfe-dev mailing list