Commit 02e819ff by Rafael Avila de Espindola Committed by Rafael Espindola

common.opt (fhelp): Add Var(help_flag).

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.

From-SVN: r146195
parent 0455c7f4
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> 2009-04-16 Richard Guenther <rguenther@suse.de>
* gimple.c (gimple_copy): Do not clear addresses_taken bitmap. * gimple.c (gimple_copy): Do not clear addresses_taken bitmap.
......
...@@ -39,7 +39,7 @@ Alias for --help=target ...@@ -39,7 +39,7 @@ Alias for --help=target
;; program's insatiable desire to turn options starting with a ;; program's insatiable desire to turn options starting with a
;; double dash (--) into options starting with a dash f (-f). ;; double dash (--) into options starting with a dash f (-f).
fhelp fhelp
Common Common Var(help_flag)
fhelp= fhelp=
Common Joined Common Joined
......
...@@ -64,6 +64,7 @@ struct plugin_pass ...@@ -64,6 +64,7 @@ struct plugin_pass
struct plugin_info struct plugin_info
{ {
const char *version; const char *version;
const char *help;
}; };
/* Function type for the plugin initialization routine. Each plugin module /* Function type for the plugin initialization routine. Each plugin module
......
...@@ -61,6 +61,7 @@ struct plugin_name_args ...@@ -61,6 +61,7 @@ struct plugin_name_args
int argc; int argc;
struct plugin_argument *argv; struct plugin_argument *argv;
const char *version; const char *version;
const char *help;
}; };
/* Hash table for the plugin_name_args objects created during command-line /* 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) ...@@ -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); void **slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT);
struct plugin_name_args *plugin = (struct plugin_name_args *) *slot; struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
plugin->version = info->version; plugin->version = info->version;
plugin->help = info->help;
} }
/* Called from the plugin's initialization code. Register a single callback. /* Called from the plugin's initialization code. Register a single callback.
...@@ -708,6 +710,51 @@ print_plugins_versions (FILE *file, const char *indent) ...@@ -708,6 +710,51 @@ print_plugins_versions (FILE *file, const char *indent)
htab_traverse_noresize (plugin_name_args_tab, print_version_one_plugin, &opt); 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. */ /* Return true if plugins have been loaded. */
......
...@@ -30,6 +30,7 @@ extern bool plugins_active_p (void); ...@@ -30,6 +30,7 @@ extern bool plugins_active_p (void);
extern void dump_active_plugins (FILE *); extern void dump_active_plugins (FILE *);
extern void debug_active_plugins (void); extern void debug_active_plugins (void);
extern void print_plugins_versions (FILE *file, const char *indent); 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); extern void finalize_plugins (void);
#endif /* PLUGIN_H */ #endif /* PLUGIN_H */
...@@ -2279,6 +2279,9 @@ toplev_main (unsigned int argc, const char **argv) ...@@ -2279,6 +2279,9 @@ toplev_main (unsigned int argc, const char **argv)
if (version_flag) if (version_flag)
print_version (stderr, ""); print_version (stderr, "");
if (help_flag)
print_plugins_help (stderr, "");
/* Exit early if we can (e.g. -help). */ /* Exit early if we can (e.g. -help). */
if (!exit_after_options) if (!exit_after_options)
do_compile (); do_compile ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment