aboutsummaryrefslogtreecommitdiff
path: root/gcc/diagnostic.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2023-11-09 17:22:52 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2023-11-09 17:22:52 -0500
commit8625aa246696695ef5c20aba847a8f39019ab8d3 (patch)
tree2f71899f2c5b2e2bbcf0b346e3825bd31ce84886 /gcc/diagnostic.h
parent0c6c9b64545c5ef87df9f025ecb90ed537054caa (diff)
downloadgcc-upstream-8625aa246696695ef5c20aba847a8f39019ab8d3.tar.gz
diagnostics: cleanups to diagnostic-show-locus.cc
Reduce implicit usage of line_table global, and move source printing to within diagnostic_context. gcc/ChangeLog: * diagnostic-show-locus.cc (layout::m_line_table): New field. (compatible_locations_p): Convert to... (layout::compatible_locations_p): ...this, replacing uses of line_table global with m_line_table. (layout::layout): Convert "richloc" param from a pointer to a const reference. Initialize m_line_table member. (layout::maybe_add_location_range): Replace uses of line_table global with m_line_table. Pass the latter to linemap_client_expand_location_to_spelling_point. (layout::print_leading_fixits): Pass m_line_table to affects_line_p. (layout::print_trailing_fixits): Likewise. (gcc_rich_location::add_location_if_nearby): Update for change to layout ctor params. (diagnostic_show_locus): Convert to... (diagnostic_context::maybe_show_locus): ...this, converting richloc param from a pointer to a const reference. Make "loc" const. Split out printing part of function to... (diagnostic_context::show_locus): ...this. (selftest::test_offset_impl): Update for change to layout ctor params. (selftest::test_layout_x_offset_display_utf8): Likewise. (selftest::test_layout_x_offset_display_tab): Likewise. (selftest::test_tab_expansion): Likewise. * diagnostic.h (diagnostic_context::maybe_show_locus): New decl. (diagnostic_context::show_locus): New decl. (diagnostic_show_locus): Convert from a decl to an inline function. * gdbinit.in (break-on-diagnostic): Update from a breakpoint on diagnostic_show_locus to one on diagnostic_context::maybe_show_locus. * genmatch.cc (linemap_client_expand_location_to_spelling_point): Add "set" param and use it in place of line_table global. * input.cc (expand_location_1): Likewise. (expand_location): Update for new param of expand_location_1. (expand_location_to_spelling_point): Likewise. (linemap_client_expand_location_to_spelling_point): Add "set" param and use it in place of line_table global. * tree-diagnostic-path.cc (event_range::print): Pass line_table for new param of linemap_client_expand_location_to_spelling_point. libcpp/ChangeLog: * include/line-map.h (rich_location::get_expanded_location): Make const. (rich_location::get_line_table): New accessor. (rich_location::m_line_table): Make the pointer be const. (rich_location::m_have_expanded_location): Make mutable. (rich_location::m_expanded_location): Likewise. (fixit_hint::affects_line_p): Add const line_maps * param. (linemap_client_expand_location_to_spelling_point): Likewise. * line-map.cc (rich_location::get_expanded_location): Make const. Pass m_line_table to linemap_client_expand_location_to_spelling_point. (rich_location::maybe_add_fixit): Likewise. (fixit_hint::affects_line_p): Add set param and pass to linemap_client_expand_location_to_spelling_point. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/diagnostic.h')
-rw-r--r--gcc/diagnostic.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 58341cec308..6a3228247b8 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -410,6 +410,10 @@ public:
m_option_classifier.pop (where);
}
+ void maybe_show_locus (const rich_location &richloc,
+ diagnostic_t diagnostic_kind,
+ pretty_printer *pp);
+
void emit_diagram (const diagnostic_diagram &diagram);
/* Various setters for use by option-handling logic. */
@@ -496,6 +500,10 @@ private:
void get_any_inlining_info (diagnostic_info *diagnostic);
+ void show_locus (const rich_location &richloc,
+ diagnostic_t diagnostic_kind,
+ pretty_printer *pp);
+
/* Data members.
Ideally, all of these would be private and have "m_" prefixes. */
@@ -816,10 +824,15 @@ diagnostic_report_current_module (diagnostic_context *context,
context->report_current_module (where);
}
-extern void diagnostic_show_locus (diagnostic_context *,
- rich_location *richloc,
- diagnostic_t diagnostic_kind,
- pretty_printer *pp = nullptr);
+inline void
+diagnostic_show_locus (diagnostic_context *context,
+ rich_location *richloc,
+ diagnostic_t diagnostic_kind,
+ pretty_printer *pp = nullptr)
+{
+ gcc_assert (richloc);
+ context->maybe_show_locus (*richloc, diagnostic_kind, pp);
+}
/* Because we read source files a second time after the frontend did it the
first time, we need to know how the frontend handled things like character