summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorespindola <espindola@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-16 14:31:45 +0000
committerespindola <espindola@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-16 14:31:45 +0000
commit2dfeb300f788760c436633d99e144ab97192d63c (patch)
treec6fbd7f9013fa3335143a10692c790200c87a198 /gcc
parent0b35ccd7157213cf19130941a2644ed76ab4304b (diff)
downloadgcc-2dfeb300f788760c436633d99e144ab97192d63c.tar.gz
2009-04-16 Rafael Avila de Espindola <espindola@google.com>
* common.opt (fhelp): Add Var(help_flag). * gcc-plugin.h (plugin_info): Add help. * plugin.c (plugin_name_args): Add help. (register_plugin_info): Set plugin->help. (print_help_one_plugin): New. (print_plugins_help): New. * plugin.h (print_plugins_help): New. * toplev.c (toplev_main): Call print_plugins_help if needed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146195 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/common.opt2
-rw-r--r--gcc/gcc-plugin.h1
-rw-r--r--gcc/plugin.c47
-rw-r--r--gcc/plugin.h1
-rw-r--r--gcc/toplev.c3
6 files changed, 64 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b442ef00f41..04eb70a1d36 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2009-04-16 Rafael Avila de Espindola <espindola@google.com>
+
+ * common.opt (fhelp): Add Var(help_flag).
+ * gcc-plugin.h (plugin_info): Add help.
+ * plugin.c (plugin_name_args): Add help.
+ (register_plugin_info): Set plugin->help.
+ (print_help_one_plugin): New.
+ (print_plugins_help): New.
+ * plugin.h (print_plugins_help): New.
+ * toplev.c (toplev_main): Call print_plugins_help if needed.
+
2009-04-16 Richard Guenther <rguenther@suse.de>
* gimple.c (gimple_copy): Do not clear addresses_taken bitmap.
diff --git a/gcc/common.opt b/gcc/common.opt
index c6903b60d71..20dd071cd7c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -39,7 +39,7 @@ Alias for --help=target
;; program's insatiable desire to turn options starting with a
;; double dash (--) into options starting with a dash f (-f).
fhelp
-Common
+Common Var(help_flag)
fhelp=
Common Joined
diff --git a/gcc/gcc-plugin.h b/gcc/gcc-plugin.h
index 8627720acd2..6865566472f 100644
--- a/gcc/gcc-plugin.h
+++ b/gcc/gcc-plugin.h
@@ -64,6 +64,7 @@ struct plugin_pass
struct plugin_info
{
const char *version;
+ const char *help;
};
/* Function type for the plugin initialization routine. Each plugin module
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 95297a7d395..4d4addd3bd8 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -61,6 +61,7 @@ struct plugin_name_args
int argc;
struct plugin_argument *argv;
const char *version;
+ const char *help;
};
/* Hash table for the plugin_name_args objects created during command-line
@@ -461,6 +462,7 @@ register_plugin_info (const char* name, struct plugin_info *info)
void **slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT);
struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
plugin->version = info->version;
+ plugin->help = info->help;
}
/* Called from the plugin's initialization code. Register a single callback.
@@ -708,6 +710,51 @@ print_plugins_versions (FILE *file, const char *indent)
htab_traverse_noresize (plugin_name_args_tab, print_version_one_plugin, &opt);
}
+/* Print help for one plugin. SLOT is the hash table slot. DATA is the
+ argument to htab_traverse_noresize. */
+
+static int
+print_help_one_plugin (void **slot, void *data)
+{
+ struct print_options *opt = (struct print_options *) data;
+ struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
+ const char *help = plugin->help ? plugin->help : "No help available .";
+
+ char *dup = xstrdup (help);
+ char *p, *nl;
+ fprintf (opt->file, " %s%s:\n", opt->indent, plugin->base_name);
+
+ for (p = nl = dup; nl; p = nl)
+ {
+ nl = strchr (nl, '\n');
+ if (nl)
+ {
+ *nl = '\0';
+ nl++;
+ }
+ fprintf (opt->file, " %s %s\n", opt->indent, p);
+ }
+
+ free (dup);
+ return 1;
+}
+
+/* Print help for each plugin. The output goes to FILE and every line starts
+ with INDENT. */
+
+void
+print_plugins_help (FILE *file, const char *indent)
+{
+ struct print_options opt;
+ opt.file = file;
+ opt.indent = indent;
+ if (!plugin_name_args_tab || htab_elements (plugin_name_args_tab) == 0)
+ return;
+
+ fprintf (file, "%sHelp for the loaded plugins:\n", indent);
+ htab_traverse_noresize (plugin_name_args_tab, print_help_one_plugin, &opt);
+}
+
/* Return true if plugins have been loaded. */
diff --git a/gcc/plugin.h b/gcc/plugin.h
index d8cf6919a4a..c1f566ba80f 100644
--- a/gcc/plugin.h
+++ b/gcc/plugin.h
@@ -30,6 +30,7 @@ extern bool plugins_active_p (void);
extern void dump_active_plugins (FILE *);
extern void debug_active_plugins (void);
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);
#endif /* PLUGIN_H */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 725c3762767..0f3d30b3b63 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2279,6 +2279,9 @@ toplev_main (unsigned int argc, const char **argv)
if (version_flag)
print_version (stderr, "");
+ if (help_flag)
+ print_plugins_help (stderr, "");
+
/* Exit early if we can (e.g. -help). */
if (!exit_after_options)
do_compile ();