]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: make m_text_callbacks private
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 14 Nov 2023 19:01:55 +0000 (14:01 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 14 Nov 2023 19:01:55 +0000 (14:01 -0500)
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>
gcc/diagnostic-show-locus.cc
gcc/diagnostic.cc
gcc/diagnostic.h
gcc/fortran/error.cc
gcc/selftest-diagnostic.cc
gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c
gcc/tree-diagnostic-path.cc

index 169f59cb057391900bfbb4e3a2c4b78ca96000b9..563d2826f249fe6ce1a1028c328dd9cd41a5ada9 100644 (file)
@@ -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
index 24212b9668eb503f8dec7cd37b0a2c5064502fc1..ccca2d2150f71f9835e129aee69bb38102541372 100644 (file)
@@ -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;
index 2489855ae4a4553b70fce09f0dad8da2ce926e40..57c5ed4f582a4657d4e320ebb700521123206560 100644 (file)
@@ -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
index ca31775c2dc3c1e102ab9380a8de902884548245..2ac51e95e4dafa841895c3d615e154dbd0eebfff 100644 (file)
@@ -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';
index 37e98ed33047ad405473a55e081d7cd6f8d44f85..f9a1852f76800945e31846e4a37b4acf553ea751 100644 (file)
@@ -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;
 }
index e8903ba6ee321888e53737f012873aa85f11c180..ce0b3225dfcaafa93e53d84ab6ac43b1fe42a081 100644 (file)
@@ -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);
index d2345c8dae746f27c26164c81d84ff40e877f8be..3cd9c210feaa5526d2ed972934798c88992f6bcc 100644 (file)
@@ -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