On Wed, 2016-08-24 at 21:13 -0400, David Malcolm wrote:
> Changed in v2: I dropped -fdiagnostics-apply-fixits
> 
> This patch uses the edit_context machinery to provide a new
> -fdiagnostics-generate-patch option.
> 
> If set an edit_context is created for global_dc, and any
> fix-it hints emitted by diagnostics are added to the edit_context.
> 
> -fdiagnostics-generate-patch writes out a patch to stderr in unified
> diff format.  This is potentially color-coded, following the same
> rules
> as for diagnostics (and affected by -fdiagnostics-color).  The color
> scheme mimics that of git-diff.
> gcc/ChangeLog:
>       * common.opt (fdiagnostics-generate-patch): New option.
>       * diagnostic.c: Include "edit-context.h".
>       (diagnostic_initialize): Initialize context->edit_context_ptr.
>       (diagnostic_finish): Delete context->edit_context_ptr.
>       (diagnostic_report_diagnostic): Add fix-it hints from the
>       diagnostic to context->edit_context_ptr, if any.
>       * diagnostic.h (class edit_context): Add forward decl.
>       (struct diagnostic_context): Add field "edit_context_ptr".
>       * doc/invoke.texi (Diagnostic Message Formatting Options): Add
>       -fdiagnostics-generate-patch.
>       (-fdiagnostics-generate-patch): New item.
>       * toplev.c: Include "edit-context.h".
>       (process_options): Set global_dc->edit_context_ptr to a new
>       edit_context if the options need one.
>       (toplev::main): Handle -fdiagnostics-generate-patch by using
>       global_dc->edit_context_ptr.
> 
> gcc/testsuite/ChangeLog:
>       * gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c:
> New
>       test case.
>       * gcc.dg/plugin/plugin.exp (plugin_test_list): Add
>       diagnostic-test-show-locus-generate-patch.c to the sources
>       for diagnostic_plugin_test_show_locus.c.


The prerequisites are in, so I've committed this to trunk (as r239965), having 
verified bootstrap&regrtest on x86_64-pc-linux-gnu.

Reply via email to