diagnostics: make m_text_callbacks private
No functional change intended. gcc/ChangeLog: * diagnostic-show-locus.cc (diagnostic_context::show_locus): Update for renaming of text callbacks fields. * diagnostic.cc (diagnostic_context::initialize): Likewise. * diagnostic.h (class diagnostic_context): Add "friend" for accessors to m_text_callbacks. (diagnostic_context::m_text_callbacks): Make private, and add an "m_" prefix to field names. (diagnostic_starter): Convert from macro to inline function. (diagnostic_start_span): New. (diagnostic_finalizer): Convert from macro to inline function. gcc/fortran/ChangeLog: * error.cc (gfc_diagnostics_init): Use diagnostic_start_span. gcc/ChangeLog: * selftest-diagnostic.cc (test_diagnostic_context::test_diagnostic_context): Use diagnostic_start_span. * tree-diagnostic-path.cc (struct event_range): Likewise. gcc/testsuite: * gcc.dg/plugin/diagnostic_group_plugin.c: Use diagnostic_start_span. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
parent
d0bfd6ba3b
commit
07e568d77f
7 changed files with 39 additions and 14 deletions
|
@ -2904,7 +2904,7 @@ diagnostic_context::show_locus (const rich_location &richloc,
|
|||
{
|
||||
expanded_location exploc
|
||||
= layout.get_expanded_location (line_span);
|
||||
m_text_callbacks.start_span (this, exploc);
|
||||
m_text_callbacks.m_start_span (this, exploc);
|
||||
}
|
||||
}
|
||||
/* Iterate over the lines within this span (using linenum_arith_t to
|
||||
|
|
|
@ -235,9 +235,9 @@ diagnostic_context::initialize (int n_opts)
|
|||
m_warn_system_headers = false;
|
||||
m_max_errors = 0;
|
||||
m_internal_error = nullptr;
|
||||
m_text_callbacks.begin_diagnostic = default_diagnostic_starter;
|
||||
m_text_callbacks.start_span = default_diagnostic_start_span_fn;
|
||||
m_text_callbacks.end_diagnostic = default_diagnostic_finalizer;
|
||||
m_text_callbacks.m_begin_diagnostic = default_diagnostic_starter;
|
||||
m_text_callbacks.m_start_span = default_diagnostic_start_span_fn;
|
||||
m_text_callbacks.m_end_diagnostic = default_diagnostic_finalizer;
|
||||
m_option_enabled = nullptr;
|
||||
m_option_state = nullptr;
|
||||
m_option_name = nullptr;
|
||||
|
|
|
@ -352,6 +352,14 @@ struct diagnostic_source_printing_options
|
|||
class diagnostic_context
|
||||
{
|
||||
public:
|
||||
/* Give access to m_text_callbacks. */
|
||||
friend diagnostic_starter_fn &
|
||||
diagnostic_starter (diagnostic_context *context);
|
||||
friend diagnostic_start_span_fn &
|
||||
diagnostic_start_span (diagnostic_context *context);
|
||||
friend diagnostic_finalizer_fn &
|
||||
diagnostic_finalizer (diagnostic_context *context);
|
||||
|
||||
typedef void (*ice_handler_callback_t) (diagnostic_context *);
|
||||
typedef void (*set_locations_callback_t) (diagnostic_context *,
|
||||
diagnostic_info *);
|
||||
|
@ -574,7 +582,6 @@ private:
|
|||
/* Maximum number of errors to report. */
|
||||
int m_max_errors;
|
||||
|
||||
public:
|
||||
/* Client-supplied callbacks for use in text output. */
|
||||
struct {
|
||||
/* This function is called before any message is printed out. It is
|
||||
|
@ -584,17 +591,18 @@ public:
|
|||
from "/home/gdr/src/nifty_printer.h:56:
|
||||
...
|
||||
*/
|
||||
diagnostic_starter_fn begin_diagnostic;
|
||||
diagnostic_starter_fn m_begin_diagnostic;
|
||||
|
||||
/* This function is called by diagnostic_show_locus in between
|
||||
disjoint spans of source code, so that the context can print
|
||||
something to indicate that a new span of source code has begun. */
|
||||
diagnostic_start_span_fn start_span;
|
||||
diagnostic_start_span_fn m_start_span;
|
||||
|
||||
/* This function is called after the diagnostic message is printed. */
|
||||
diagnostic_finalizer_fn end_diagnostic;
|
||||
diagnostic_finalizer_fn m_end_diagnostic;
|
||||
} m_text_callbacks;
|
||||
|
||||
public:
|
||||
/* Client hook to report an internal error. */
|
||||
void (*m_internal_error) (diagnostic_context *, const char *, va_list *);
|
||||
|
||||
|
@ -734,11 +742,28 @@ diagnostic_inhibit_notes (diagnostic_context * context)
|
|||
|
||||
/* Client supplied function to announce a diagnostic
|
||||
(for text-based diagnostic output). */
|
||||
#define diagnostic_starter(DC) (DC)->m_text_callbacks.begin_diagnostic
|
||||
inline diagnostic_starter_fn &
|
||||
diagnostic_starter (diagnostic_context *context)
|
||||
{
|
||||
return context->m_text_callbacks.m_begin_diagnostic;
|
||||
}
|
||||
|
||||
/* Client supplied function called between disjoint spans of source code,
|
||||
so that the context can print
|
||||
something to indicate that a new span of source code has begun. */
|
||||
inline diagnostic_start_span_fn &
|
||||
diagnostic_start_span (diagnostic_context *context)
|
||||
{
|
||||
return context->m_text_callbacks.m_start_span;
|
||||
}
|
||||
|
||||
/* Client supplied function called after a diagnostic message is
|
||||
displayed (for text-based diagnostic output). */
|
||||
#define diagnostic_finalizer(DC) (DC)->m_text_callbacks.end_diagnostic
|
||||
inline diagnostic_finalizer_fn &
|
||||
diagnostic_finalizer (diagnostic_context *context)
|
||||
{
|
||||
return context->m_text_callbacks.m_end_diagnostic;
|
||||
}
|
||||
|
||||
/* Extension hooks for client. */
|
||||
#define diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data
|
||||
|
|
|
@ -1637,7 +1637,7 @@ void
|
|||
gfc_diagnostics_init (void)
|
||||
{
|
||||
diagnostic_starter (global_dc) = gfc_diagnostic_starter;
|
||||
global_dc->m_text_callbacks.start_span = gfc_diagnostic_start_span;
|
||||
diagnostic_start_span (global_dc) = gfc_diagnostic_start_span;
|
||||
diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
|
||||
diagnostic_format_decoder (global_dc) = gfc_format_decoder;
|
||||
global_dc->m_source_printing.caret_chars[0] = '1';
|
||||
|
|
|
@ -39,7 +39,7 @@ test_diagnostic_context::test_diagnostic_context ()
|
|||
m_source_printing.enabled = true;
|
||||
m_source_printing.show_labels_p = true;
|
||||
m_show_column = true;
|
||||
m_text_callbacks.start_span = start_span_cb;
|
||||
diagnostic_start_span (this) = start_span_cb;
|
||||
m_source_printing.min_margin_width = 6;
|
||||
m_source_printing.max_width = 80;
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ plugin_init (struct plugin_name_args *plugin_info,
|
|||
return 1;
|
||||
|
||||
diagnostic_starter (global_dc) = test_diagnostic_starter;
|
||||
global_dc->m_text_callbacks.start_span = test_diagnostic_start_span_fn;
|
||||
diagnostic_start_span (global_dc) = test_diagnostic_start_span_fn;
|
||||
global_dc->set_output_format (new test_output_format (*global_dc));
|
||||
|
||||
pass_info.pass = new pass_test_groups (g);
|
||||
|
|
|
@ -206,7 +206,7 @@ struct event_range
|
|||
= linemap_client_expand_location_to_spelling_point
|
||||
(line_table, initial_loc, LOCATION_ASPECT_CARET);
|
||||
if (exploc.file != LOCATION_FILE (dc->m_last_location))
|
||||
dc->m_text_callbacks.start_span (dc, exploc);
|
||||
diagnostic_start_span (dc) (dc, exploc);
|
||||
}
|
||||
|
||||
/* If we have an UNKNOWN_LOCATION (or BUILTINS_LOCATION) as the
|
||||
|
|
Loading…
Add table
Reference in a new issue