aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include/line-map.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-06-22 14:42:30 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-06-22 14:42:30 +0000
commita93eac6a845d79a77646068b98cbd90a9be7b58a (patch)
tree8d46c6412fd67294b9c6633443b3ccd90df9a278 /libcpp/include/line-map.h
parentd53c0398155c0374fd73764bb208d0229b7a7ff1 (diff)
downloadgcc-a93eac6a845d79a77646068b98cbd90a9be7b58a.zip
gcc-a93eac6a845d79a77646068b98cbd90a9be7b58a.tar.gz
gcc-a93eac6a845d79a77646068b98cbd90a9be7b58a.tar.bz2
Implement -fdiagnostics-parseable-fixits
gcc/ChangeLog: * common.opt (fdiagnostics-parseable-fixits): New option. * diagnostic.c: Include "selftest.h". (print_escaped_string): New function. (print_parseable_fixits): New function. (diagnostic_report_diagnostic): Call print_parseable_fixits. (selftest::assert_print_escaped_string): New function. (ASSERT_PRINT_ESCAPED_STRING_STREQ): New macro. (selftest::test_print_escaped_string): New function. (selftest::test_print_parseable_fixits_none): New function. (selftest::test_print_parseable_fixits_insert): New function. (selftest::test_print_parseable_fixits_remove): New function. (selftest::test_print_parseable_fixits_replace): New function. (selftest::diagnostic_c_tests): New function. * diagnostic.h (struct diagnostic_context): Add field "parseable_fixits_p". * doc/invoke.texi (Diagnostic Message Formatting Options): Add -fdiagnostics-parseable-fixits. (-fdiagnostics-parseable-fixits): New option. * opts.c (common_handle_option): Handle -fdiagnostics-parseable-fixits. * selftest-run-tests.c (selftest::run_tests): Call selftest::diagnostic_c_tests. * selftest.h (selftest::diagnostic_c_tests): New prototype. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-show-locus-parseable-fixits.c: New file. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add diagnostic-test-show-locus-parseable-fixits.c to sources for diagnostic_plugin_test_show_locus.c. * lib/gcc-defs.exp (freeform_regexps): New global. (dg-regexp): New function. (handle-dg-regexps): New function. * lib/gcc-dg.exp (cleanup-after-saved-dg-test): Reset freeform_regexps to the empty list. * lib/prune.exp (prune_gcc_output): Call handle-dg-regexps. libcpp/ChangeLog: * include/line-map.h (fixit_hint::get_start_loc): New pure virtual function. (fixit_hint::maybe_get_end_loc): Likewise. (fixit_insert::get_start_loc): New function, implementing fixit_hint::get_start_loc. (fixit_insert::maybe_get_end_loc): New function, implementing fixit_hint::maybe_get_end_loc. (fixit_remove::get_start_loc): New function, implementing fixit_hint::get_start_loc. (fixit_remove::maybe_get_end_loc): New function, implementing fixit_hint::maybe_get_end_loc. (fixit_replace::get_start_loc): New function, implementing fixit_hint::get_start_loc. (fixit_replace::maybe_get_end_loc): New function, implementing fixit_hint::maybe_get_end_loc. From-SVN: r237712
Diffstat (limited to 'libcpp/include/line-map.h')
-rw-r--r--libcpp/include/line-map.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 292abce..416419c 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1418,6 +1418,8 @@ public:
virtual enum kind get_kind () const = 0;
virtual bool affects_line_p (const char *file, int line) = 0;
+ virtual source_location get_start_loc () const = 0;
+ virtual bool maybe_get_end_loc (source_location *out) const = 0;
};
class fixit_insert : public fixit_hint
@@ -1428,6 +1430,8 @@ class fixit_insert : public fixit_hint
~fixit_insert ();
enum kind get_kind () const { return INSERT; }
bool affects_line_p (const char *file, int line);
+ source_location get_start_loc () const { return m_where; }
+ bool maybe_get_end_loc (source_location *) const { return false; }
source_location get_location () const { return m_where; }
const char *get_string () const { return m_bytes; }
@@ -1447,6 +1451,12 @@ class fixit_remove : public fixit_hint
enum kind get_kind () const { return REMOVE; }
bool affects_line_p (const char *file, int line);
+ source_location get_start_loc () const { return m_src_range.m_start; }
+ bool maybe_get_end_loc (source_location *out) const
+ {
+ *out = m_src_range.m_finish;
+ return true;
+ }
source_range get_range () const { return m_src_range; }
@@ -1463,6 +1473,12 @@ class fixit_replace : public fixit_hint
enum kind get_kind () const { return REPLACE; }
bool affects_line_p (const char *file, int line);
+ source_location get_start_loc () const { return m_src_range.m_start; }
+ bool maybe_get_end_loc (source_location *out) const
+ {
+ *out = m_src_range.m_finish;
+ return true;
+ }
source_range get_range () const { return m_src_range; }
const char *get_string () const { return m_bytes; }