(root)/
gcc-13.2.0/
gcc/
testsuite/
g++.dg/
plugin/
def_plugin.c
       1  /* A plugin example that shows which function definitions are caught by PLUGIN_START_FUNCTION and PLUGIN_FINISH_FUNCTION */
       2  
       3  #include "gcc-plugin.h"
       4  #include <stdlib.h>
       5  #include "config.h"
       6  #include "system.h"
       7  #include "coretypes.h"
       8  #include "tree.h"
       9  #include "tree-pass.h"
      10  #include "intl.h"
      11  #include "diagnostic.h"
      12  
      13  int plugin_is_GPL_compatible;
      14  
      15  /* Callback function to invoke when GCC starts a function definition*/
      16  
      17  void plugin_start_parse_function (void *event_data, void *data)
      18  {
      19    tree fndef = (tree) event_data;
      20    warning (0, G_("Start fndef %s"),
      21             IDENTIFIER_POINTER (DECL_NAME (fndef)));
      22  }
      23  
      24  /* Callback function to invoke after GCC finishes a function definition. */
      25  
      26  void plugin_finish_parse_function (void *event_data, void *data)
      27  {
      28    tree fndef = (tree) event_data;
      29    warning (0, G_("Finish fndef %s"),
      30             IDENTIFIER_POINTER (DECL_NAME (fndef)));
      31  }
      32  
      33  int
      34  plugin_init (struct plugin_name_args *plugin_info,
      35               struct plugin_gcc_version *version)
      36  {
      37    const char *plugin_name = plugin_info->base_name;
      38  
      39    register_callback (plugin_name, PLUGIN_START_PARSE_FUNCTION,
      40                       plugin_start_parse_function, NULL);
      41  
      42    register_callback (plugin_name, PLUGIN_FINISH_PARSE_FUNCTION,
      43                       plugin_finish_parse_function, NULL);
      44    return 0;
      45  }