gccint: Plugins attr

1 
1 24.6 Registering custom attributes or pragmas
1 =============================================
1 
1 For analysis (or other) purposes it is useful to be able to add custom
1 attributes or pragmas.
1 
1  The 'PLUGIN_ATTRIBUTES' callback is called during attribute
1 registration.  Use the 'register_attribute' function to register custom
1 attributes.
1 
1      /* Attribute handler callback */
1      static tree
1      handle_user_attribute (tree *node, tree name, tree args,
1                             int flags, bool *no_add_attrs)
1      {
1        return NULL_TREE;
1      }
1 
1      /* Attribute definition */
1      static struct attribute_spec user_attr =
1        { "user", 1, 1, false,  false, false, false, handle_user_attribute, NULL };
1 
1      /* Plugin callback called during attribute registration.
1      Registered with register_callback (plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL)
1      */
1      static void
1      register_attributes (void *event_data, void *data)
1      {
1        warning (0, G_("Callback to register attributes"));
1        register_attribute (&user_attr);
1      }
1 
1 
1  The PLUGIN_PRAGMAS callback is called once during pragmas registration.
1 Use the 'c_register_pragma', 'c_register_pragma_with_data',
1 'c_register_pragma_with_expansion',
1 'c_register_pragma_with_expansion_and_data' functions to register custom
1 pragmas and their handlers (which often want to call 'pragma_lex') from
1 'c-family/c-pragma.h'.
1 
1      /* Plugin callback called during pragmas registration. Registered with
1           register_callback (plugin_name, PLUGIN_PRAGMAS,
1                              register_my_pragma, NULL);
1      */
1      static void
1      register_my_pragma (void *event_data, void *data)
1      {
1        warning (0, G_("Callback to register pragmas"));
1        c_register_pragma ("GCCPLUGIN", "sayhello", handle_pragma_sayhello);
1      }
1 
1  It is suggested to pass '"GCCPLUGIN"' (or a short name identifying your
1 plugin) as the "space" argument of your pragma.
1 
1  Pragmas registered with 'c_register_pragma_with_expansion' or
1 'c_register_pragma_with_expansion_and_data' support preprocessor
1 expansions.  For example:
1 
1      #define NUMBER 10
1      #pragma GCCPLUGIN foothreshold (NUMBER)
1