Next:Recording information about pass execution, Previous:Giving information about a plugin, Up:Plugins [Contents][Index]
For analysis (or other) purposes it is useful to be able to add customattributes or pragmas.
ThePLUGIN_ATTRIBUTES callback is called during attributeregistration. Use theregister_attribute function to registercustom attributes.
/* Attribute handler callback */static treehandle_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, false, handle_user_attribute, NULL };/* Plugin callback called during attribute registration.Registered with register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL)*/static voidregister_attributes (void *event_data, void *data){ warning (0, G_("Callback to register attributes")); register_attribute (&user_attr);}ThePLUGIN_PRAGMAS callback is called once during pragmasregistration. Use thec_register_pragma,c_register_pragma_with_data,c_register_pragma_with_expansion,c_register_pragma_with_expansion_and_data functions to registercustom pragmas and their handlers (which often want to callpragma_lex) fromc-family/c-pragma.h.
/* Plugin callback called during pragmas registration. Registered with register_callback (plugin_name, PLUGIN_PRAGMAS, register_my_pragma, NULL);*/static voidregister_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 identifyingyour plugin) as the “space” argument of your pragma.
Pragmas registered withc_register_pragma_with_expansion orc_register_pragma_with_expansion_and_data supportpreprocessor expansions. For example:
#define NUMBER 10#pragma GCCPLUGIN foothreshold (NUMBER)