view src/cospy.c @ 4:8855f7d934ae

Get name of functions before exceuting all_passes
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 08 Sep 2010 17:46:29 +0800
parents 92347d3a3bf3
children a32f4bd19eda
line wrap: on
line source

#include "gcc-plugin.h"
#include "plugin-version.h"
#include "system.h"
#include "coretypes.h"
#include "tree-pass.h"
#include "tree.h"
#include "gimple.h"
#include "cgraph.h"
#include <stdio.h>

int plugin_is_GPL_compatible;

static void
handle_all_passes(void *gcc_data, void *user_data) {
    tree decl;
    
    decl = cfun->decl;
    printf("decl %x\n", decl);
    printf("  %s\n", current_function_name());
}

int
plugin_init(struct plugin_name_args *plugin_info,
	    struct plugin_gcc_version *version) {
    struct cgraph_node_hook_list *hook;
    
    if (!plugin_default_version_check (version, &gcc_version))
	return 1;
    printf("Initialize plugin %s\n", plugin_info->base_name);

    register_callback(plugin_info->base_name, PLUGIN_ALL_PASSES_START,
		      handle_all_passes, NULL);
    return 0;
}