Next: Plugins recording, Previous: Plugins description, Up: Plugins
For analysis (or other) purposes it is useful to be able to add custom attributes or pragmas.
The PLUGIN_ATTRIBUTES callback is called during attribute
registration. Use the register_attribute function to register
custom attributes.
/* Attribute handler callback */
static tree
handle_user_attribute (tree *node, tree name, tree args,
int flags, bool *no_add_attrs)
{
return NULL_TREE;
}
/* Attribute definition */
static struct attribute_spec user_attr =
{ "user", 1, 1, false, false, false, handle_user_attribute, false };
/* Plugin callback called during attribute registration.
Registered with register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL)
*/
static void
register_attributes (void *event_data, void *data)
{
warning (0, G_("Callback to register attributes"));
register_attribute (&user_attr);
}
The PLUGIN_PRAGMAS callback is called during pragmas
registration. Use the c_register_pragma or
c_register_pragma_with_expansion functions to register custom
pragmas.
/* Plugin callback called during pragmas registration. Registered with
register_callback (plugin_name, PLUGIN_PRAGMAS,
register_my_pragma, NULL);
*/
static void
register_my_pragma (void *event_data, void *data)
{
warning (0, G_("Callback to register pragmas"));
c_register_pragma ("GCCPLUGIN", "sayhello", handle_pragma_sayhello);
}
It is suggested to pass "GCCPLUGIN" (or a short name identifying
your plugin) as the “space” argument of your pragma.