aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/plugin.c15
-rw-r--r--gcc/plugin.h26
3 files changed, 39 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6da5d35..e768989 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2010-04-29 Brian Hackett <bhackett1024@gmail.com>
+
+ * plugin.h (invoke_plugin_callbacks): New inline function.
+ * plugin.c (flag_plugin_added): New global flag.
+ (add_new_plugin): Initialize above flag.
+ (invoke_plugin_callbacks): Rename to ...
+ (invoke_plugin_callbacks_full): ... this.
+
2010-04-28 Jan Hubicka <jh@suse.cz>
* lto-symtab.c (lto_symtab_entry_def) Add vnode.
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 9e1b5f4..707d2dd 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -86,6 +86,8 @@ struct callback_info
static struct callback_info *plugin_callbacks_init[PLUGIN_EVENT_FIRST_DYNAMIC];
static struct callback_info **plugin_callbacks = plugin_callbacks_init;
+/* For invoke_plugin_callbacks(), see plugin.h. */
+bool flag_plugin_added = false;
#ifdef ENABLE_PLUGIN
/* Each plugin should define an initialization function with exactly
@@ -137,6 +139,8 @@ add_new_plugin (const char* plugin_name)
bool name_is_short;
const char *pc;
+ flag_plugin_added = true;
+
/* Replace short names by their full path when relevant. */
name_is_short = !IS_ABSOLUTE_PATH (plugin_name);
for (pc = plugin_name; name_is_short && *pc; pc++)
@@ -483,16 +487,11 @@ unregister_callback (const char *plugin_name, int event)
return PLUGEVT_NO_CALLBACK;
}
-/* Called from inside GCC. Invoke all plug-in callbacks registered with
- the specified event.
- Return PLUGEVT_SUCCESS if at least one callback was called,
- PLUGEVT_NO_CALLBACK if there was no callback.
-
- EVENT - the event identifier
- GCC_DATA - event-specific data provided by the compiler */
+/* Invoke all plugin callbacks registered with the specified event,
+ called from invoke_plugin_callbacks(). */
int
-invoke_plugin_callbacks (int event, void *gcc_data)
+invoke_plugin_callbacks_full (int event, void *gcc_data)
{
int retval = PLUGEVT_SUCCESS;
diff --git a/gcc/plugin.h b/gcc/plugin.h
index 1e1dd59..13628ec9 100644
--- a/gcc/plugin.h
+++ b/gcc/plugin.h
@@ -1,5 +1,5 @@
/* Header file for internal GCC plugin mechanism.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC.
@@ -26,7 +26,7 @@ struct attribute_spec;
extern void add_new_plugin (const char *);
extern void parse_plugin_arg_opt (const char *);
-extern int invoke_plugin_callbacks (int, void *);
+extern int invoke_plugin_callbacks_full (int, void *);
extern void initialize_plugins (void);
extern bool plugins_active_p (void);
extern void dump_active_plugins (FILE *);
@@ -35,6 +35,28 @@ extern void print_plugins_versions (FILE *file, const char *indent);
extern void print_plugins_help (FILE *file, const char *indent);
extern void finalize_plugins (void);
+/* Called from inside GCC. Invoke all plugin callbacks registered with
+ the specified event.
+ Return PLUGEVT_SUCCESS if at least one callback was called,
+ PLUGEVT_NO_CALLBACK if there was no callback.
+
+ EVENT - the event identifier
+ GCC_DATA - event-specific data provided by the compiler */
+
+static inline int
+invoke_plugin_callbacks (int event, void *gcc_data)
+{
+#ifdef ENABLE_PLUGIN
+ /* True iff at least one plugin has been added. */
+ extern bool flag_plugin_added;
+
+ if (flag_plugin_added)
+ return invoke_plugin_callbacks_full (event, gcc_data);
+#endif
+
+ return PLUGEVT_NO_CALLBACK;
+}
+
/* In attribs.c. */
extern void register_attribute (const struct attribute_spec *attr);