Romain Geissler <[email protected]> a écrit:
> I just checked again, and PLUGIN_FINISH_DECL is triggered for a
> typedef in C mode, but not in C++ mode. I'll patch that.
Correct. This is because the event is emitted at the end of
cp_finish_decl, but that function has many return points. Maybe
unifying all the those return points by replacing them with "goto out;"
and adding an "out" label right at the end, before emitting the event.
> When i recontributed the PLUGIN_FINISH_DECL patch from the original
> Brian Hackett, i didn't exactly checked what may or may not trigger
> this new event. I know for example that declaring a function triggers
> this event, but defining it does not.
>
> I don't really know when those event should be triggered, we should
> clarify the meaning of those.
>
> According to me:
> PLUGIN_FINISH_DECL should be triggered anytime the parser parse a
> declaration (which includes declaration + definition of function,
> typedef definition, namespaces, ..., all DECL_P trees built by the
> parser).
The general idea sounds sensible, IMHO. However, we must keep in mind
that there are cases like, e.g, 'struct C;' where G++ creates a typedef
'typedef struct C C;' so that you can name that type 'C' instead of
having to type "struct C' all the time. For these cases, I don't think
the PLUGIN_FINISH_DECL event should be emitted.
> For, PLUGIN_FINISH_TYPE i don't really know it means a new type
> declaration (or declaration + definition) or if it means usage of a
> type (in a function prototype, the type of a local variable.
I'd say it's a definition of a new type, IMHO.
> I would rather vote for new type definition (including typedefs)
My understanding is that a typedef declaration doesn't define a new
type. Rather, it declares an alias for an existing type. As such, I
would think that notifying typedef declarations via PLUGIN_FINISH_DECL
would be the way to go.
> but for special cases of struct, you can declare and use them at the
> same time:
Just to be sure I understand, do you need to be notified about *uses* of
types and decls as well? If so, maybe a new kind of event should
probably be defined, because PLUGIN_FINISH_DECL and PLUGIN_FINISH_TYPE
seem to have more to do with declaring/defining decls and types than
using them.
> So, what the real meaning of all those events ?
From plugin.def, I read:
/* After finishing parsing a type. */
DEFEVENT (PLUGIN_FINISH_TYPE)
/* After finishing parsing a declaration. */
DEFEVENT (PLUGIN_FINISH_DECL)
I agree that's rather terse, but it doesn't seem to be related to the
use of the type/decls.
--
Dodji