This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [plugins][patch] Print plugin help.
On Wed, Apr 8, 2009 at 02:17, Rafael Espindola <espindola@google.com> wrote:
>> OK with:
>
> You approved the second patch but not the first one :-)
Gah, sorry!
> I have attached both and updated them with the comments.
>
> version.patch:
>
> 2009-04-08 ÂRafael Avila de Espindola Â<espindola@google.com>
> Â Â Â Â* gcc-plugin.h (plugin_event): Add PLUGIN_INFO.
> Â Â Â Â(plugin_info): New.
> Â Â Â Â* opts.c (common_handle_option): Don't call print_version.
> Â Â Â Â* plugin.c (plugin_name_args): Add version.
> Â Â Â Â(register_plugin_info): New.
> Â Â Â Â(register_callback): Handle PLUGIN_INFO.
> Â Â Â Â(try_init_one_plugin): New.
> Â Â Â Â(init_one_plugin): Use try_init_one_plugin.
> Â Â Â Â(finalize_one_plugin): New.
> Â Â Â Â(finalize_plugins): New.
> Â Â Â Â(print_options): New.
> Â Â Â Â(print_version_one_plugin): New.
> Â Â Â Â(print_plugins_versions): New.
> Â Â Â Â* plugin.h (print_plugins_versions): New.
> Â Â Â Â(finalize_plugins): New.
> Â Â Â Â* toplev.c (compile_file): Don't call initialize_plugins.
> Â Â Â Â(print_version): Call print_plugins_versions.
> Â Â Â Â(toplev_main): Call initialize_plugins. Call print_version if needed.
> Â Â Â ÂCall finalize_plugins.
>
> help.patch:
> 2009-04-08 Â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-08 ÂRafael Avila de Espindola Â<espindola@google.com>
> Â Â Â Â* g++.dg/plugin/selfassign.c (plugin_init): Add version and help.
> Â Â Â Â* gcc.dg/plugin/selfassign.c (plugin_init): Add version and help.
OK with:
> +
> +/* Print help for one plugin. */
> +static int
Blank line after comment.
> + char *dup = xstrdup (help);
> + char *p, *nl;
> + fprintf(opt->file, " %s%s:\n", opt->indent, plugin->base_name);
Space before '('.
I wonder if we should just print nothing if there is no help
associated. If there are very many plugins loaded, we'd be
printing "No help available" quite a bit. Not too important,
though.
> + }
> + fprintf(opt->file, " %s %s\n", opt->indent, p);
Space before '('.
> +
> +/* Print help for each plugin. */
> +void
Blank line after comment.
> @@ -27,6 +27,7 @@ enum plugin_event
> PLUGIN_FINISH_UNIT, /* Useful for summary processing. */
> PLUGIN_CXX_CP_PRE_GENERICIZE, /* Allows to see low level AST in C++ FE. */
> PLUGIN_FINISH, /* Called before GCC exits. */
> + PLUGIN_INFO, /* Infomation about the plugin */
S/Infomation/Information/
>
> +struct plugin_info
> +{
Needs comment.
>
> +static void
> +register_plugin_info (const char* name, struct plugin_info *info)
Needs comment.
> +}
> +
> +static int
> +finalize_one_plugin (void **slot, void * ARG_UNUSED (info))
> +{
Needs comment.
> + struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
> + XDELETE (plugin);
> + return 1;
> +}
> +
> +void
> +finalize_plugins(void)
> +{
Needs comment.
> +
> +/* Print the version of one plugin. */
> +static int
> +print_version_one_plugin (void **slot, void *data)
Blank line after comment.
> +
> +/* Print the version of each plugin. */
> +void
> +print_plugins_versions (FILE *file, const char *indent)
Likewise.
Diego.