This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCC Plugin Callback on template instantiation (or constexpr call evaluation)


For a GCC plugin, is there a way to have a callback registered/get
called on template instantiation of a type with an attribute or some
other means? Consider:

template<typename T> struct foo { typedef T __attribute__((bar)) type; };

void foobar(foo<int*>::type);

In this case, the attribute handler callback gets called on the
template definition when it registers the attribute, not instantiation
in foobar which is what I need because I want to do some "processing"
on the type (which in this case is int*). For instance, remove the
POINTER_TYPE from it (which can easily be done with metaprogramming
but that's beside the point for this simple exercise, obviously).

Just as a note, I don't mind overriding any hooks (lang_hooks or
targetm or otherwise) if need be (and call the old one in a chain), or
just using plain plugin events, or other callbacks, etc.

An alternative way would be if I could intercept a constexpr call
evaluation in a plugin event, so then I can defer the whole thing to a
decltype of the plugin's function. There was a patch to add a
PLUGIN_EVAL_CALL_CONSTEXPR event a year ago but I've no idea what
happened to it.

I'm aware it's probably not possible at the moment but maybe I'm
missing something non-obvious. If it must be patched, hopefully a very
simple hook can be added for this purpose since it would help a lot
with plugins extending metaprogramming like this. Thanks.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]