https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62314

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Author: dmalcolm
Date: Fri Nov 20 20:08:47 2015
New Revision: 230674

URL: https://gcc.gnu.org/viewcvs?rev=230674&root=gcc&view=rev
Log:
PR 62314: add ability to add fixit-hints to a diagnostic

This is the combination of two patches:
  [PATCH 01/02] PR/62314: add ability to add fixit-hints
  [PATCH 02/02] C FE: add fix-it hint for . vs ->

gcc/ChangeLog:
        PR 62314
        * diagnostic-show-locus.c (colorizer::set_fixit_hint): New.
        (class layout): Update comment
        (layout::print_any_fixits): New method.
        (layout::move_to_column): New method.
        (diagnostic_show_locus): Add call to layout.print_any_fixits.

gcc/c/ChangeLog:
        PR 62314
        * c-typeck.c (should_suggest_deref_p): New function.
        (build_component_ref): Special-case POINTER_TYPE when
        generating a "not a structure of union"  error message, and
        suggest a "->" rather than a ".", providing a fix-it hint.

gcc/testsuite/ChangeLog:
        PR 62314
        * gcc.dg/fixits.c: New file.
        * gcc.dg/plugin/diagnostic-test-show-locus-ascii-bw.c
        (test_fixit_insert): New.
        (test_fixit_remove): New.
        (test_fixit_replace): New.
        * gcc.dg/plugin/diagnostic-test-show-locus-ascii-color.c
        (test_fixit_insert): New.
        (test_fixit_remove): New.
        (test_fixit_replace): New.
        * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
        (test_show_locus): Add tests of rendering fixit hints.

libcpp/ChangeLog:
        PR 62314
        * include/line-map.h (source_range::intersects_line_p): New
        method.
        (rich_location::~rich_location): New.
        (rich_location::add_fixit_insert): New method.
        (rich_location::add_fixit_remove): New method.
        (rich_location::add_fixit_replace): New method.
        (rich_location::get_num_fixit_hints): New accessor.
        (rich_location::get_fixit_hint): New accessor.
        (rich_location::MAX_FIXIT_HINTS): New constant.
        (rich_location::m_num_fixit_hints): New field.
        (rich_location::m_fixit_hints): New field.
        (class fixit_hint): New class.
        (class fixit_insert): New class.
        (class fixit_remove): New class.
        (class fixit_replace): New class.
        * line-map.c (source_range::intersects_line_p): New method.
        (rich_location::rich_location): Add initialization of
        m_num_fixit_hints to both ctors.
        (rich_location::~rich_location): New.
        (rich_location::add_fixit_insert): New method.
        (rich_location::add_fixit_remove): New method.
        (rich_location::add_fixit_replace): New method.
        (fixit_insert::fixit_insert): New.
        (fixit_insert::~fixit_insert): New.
        (fixit_insert::affects_line_p): New.
        (fixit_remove::fixit_remove): New.
        (fixit_remove::affects_line_p): New.
        (fixit_replace::fixit_replace): New.
        (fixit_replace::~fixit_replace): New.
        (fixit_replace::affects_line_p): New.


Added:
    trunk/gcc/testsuite/gcc.dg/fixits.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-typeck.c
    trunk/gcc/diagnostic-show-locus.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw.c
    trunk/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c
    trunk/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
    trunk/libcpp/ChangeLog
    trunk/libcpp/include/line-map.h
    trunk/libcpp/line-map.c

Reply via email to