Add gcc_rich_location::add_fixit_insert_formatted
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 1 May 2018 00:10:10 +0000 (00:10 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 1 May 2018 00:10:10 +0000 (00:10 +0000)
commit1a3a7b4eeb0444148adc4f007b91e120814c4cc5
treeea1a9a931bb387718caee06b1c2785faf6296e9c
parent47ae164c051c575234f4bef916f10346765d9565
Add gcc_rich_location::add_fixit_insert_formatted

This patch adds a support function to class gcc_rich_location
to make it easier for fix-it hints to use idiomatic C/C++
indentation, for use by the patch for PR c++/85523.

gcc/ChangeLog:
PR c++/85523
* gcc-rich-location.c (blank_line_before_p): New function.
(use_new_line): New function.
(gcc_rich_location::add_fixit_insert_formatted): New function.
* gcc-rich-location.h
(gcc_rich_location::add_fixit_insert_formatted): New function.

gcc/testsuite/ChangeLog:
PR c++/85523
* gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c
(test_add_fixit_insert_formatted_single_line): New function.
(test_add_fixit_insert_formatted_multiline): New function.
Extend expected output of generated patch to include fix-it hints
for these.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Include
"gcc-rich-location.h".  Add test coverage for
gcc_rich_location::add_fixit_insert_formatted.

From-SVN: r259783
gcc/ChangeLog
gcc/gcc-rich-location.c
gcc/gcc-rich-location.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c