]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: eliminate diagnostic_context::m_print_path callback
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 18 Jun 2024 14:59:56 +0000 (10:59 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 18 Jun 2024 14:59:56 +0000 (10:59 -0400)
No functional change intended.

gcc/ChangeLog:
* diagnostic-format-json.cc (diagnostic_output_format_init_json):
Replace clearing of diagnostic_context::m_print_path callback with
setting the path format to DPF_NONE.
* diagnostic-format-sarif.cc
(diagnostic_output_format_init_sarif): Likewise.
* diagnostic.cc (diagnostic_context::show_any_path): Replace call
to diagnostic_context::m_print_path callback with a direct call to
diagnostic_context::print_path.
* diagnostic.h (diagnostic_context::print_path): New decl.
(diagnostic_context::m_print_path): Delete callback.
* tree-diagnostic-path.cc (default_tree_diagnostic_path_printer):
Convert to...
(diagnostic_context::print_path): ...this.
* tree-diagnostic.cc (tree_diagnostics_defaults): Delete
initialization of m_print_path.
* tree-diagnostic.h (default_tree_diagnostic_path_printer): Delete
decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/diagnostic-format-json.cc
gcc/diagnostic-format-sarif.cc
gcc/diagnostic.cc
gcc/diagnostic.h
gcc/tree-diagnostic-path.cc
gcc/tree-diagnostic.cc
gcc/tree-diagnostic.h

index 2bdc2c13d37b4e18942b0053f334f52285a03a45..ec03ac15aebabbf77a3178870c87d66be56ad1b5 100644 (file)
@@ -395,8 +395,8 @@ private:
 static void
 diagnostic_output_format_init_json (diagnostic_context *context)
 {
-  /* Override callbacks.  */
-  context->m_print_path = nullptr; /* handled in json_end_diagnostic.  */
+  /* Suppress normal textual path output.  */
+  context->set_path_format (DPF_NONE);
 
   /* The metadata is handled in JSON format, rather than as text.  */
   context->set_show_cwe (false);
index 79116f051bc12fbf94bdd3be286888136d28202b..5f438dd38a886e0f6df881936361c1cbad906f5a 100644 (file)
@@ -1991,8 +1991,10 @@ private:
 static void
 diagnostic_output_format_init_sarif (diagnostic_context *context)
 {
+  /* Suppress normal textual path output.  */
+  context->set_path_format (DPF_NONE);
+
   /* Override callbacks.  */
-  context->m_print_path = nullptr; /* handled in sarif_end_diagnostic.  */
   context->set_ice_handler_callback (sarif_ice_handler);
 
   /* The metadata is handled in SARIF format, rather than as text.  */
index 844eb8e1048277c27798aae9309c5ccfcf825607..471135f16dece506c54d28aa0600fdbcfef656b1 100644 (file)
@@ -915,8 +915,7 @@ diagnostic_context::show_any_path (const diagnostic_info &diagnostic)
   if (!path)
     return;
 
-  if (m_print_path)
-    m_print_path (this, path);
+  print_path (path);
 }
 
 /* class diagnostic_event.  */
index ff2aa3dd9a322613205113f8adfdc289cdac4f6e..c6846525da3125d2c984b3604bc9892a08d81202 100644 (file)
@@ -583,6 +583,8 @@ private:
                   pretty_printer *pp,
                   diagnostic_source_effect_info *effect_info);
 
+  void print_path (const diagnostic_path *path);
+
   /* Data members.
      Ideally, all of these would be private and have "m_" prefixes.  */
 
@@ -712,8 +714,6 @@ private:
   urlifier *m_urlifier;
 
 public:
-  void (*m_print_path) (diagnostic_context *, const diagnostic_path *);
-
   /* Auxiliary data for client.  */
   void *m_client_aux_data;
 
index adaaf30b84fda2e2f546931024c43316364d2418..35f8ea2b8b62140cae3888fff4994e1382c7f737 100644 (file)
@@ -884,17 +884,16 @@ print_path_summary_as_text (const path_summary *ps, diagnostic_context *dc,
 
 } /* end of anonymous namespace for path-printing code.  */
 
-/* Print PATH to CONTEXT, according to CONTEXT's path_format.  */
+/* Print PATH according to this context's path_format.  */
 
 void
-default_tree_diagnostic_path_printer (diagnostic_context *context,
-                                     const diagnostic_path *path)
+diagnostic_context::print_path (const diagnostic_path *path)
 {
   gcc_assert (path);
 
   const unsigned num_events = path->num_events ();
 
-  switch (context->get_path_format ())
+  switch (get_path_format ())
     {
     case DPF_NONE:
       /* Do nothing.  */
@@ -909,7 +908,7 @@ default_tree_diagnostic_path_printer (diagnostic_context *context,
            label_text event_text (event.get_desc (false));
            gcc_assert (event_text.get ());
            diagnostic_event_id_t event_id (i);
-           if (context->show_path_depths_p ())
+           if (this->show_path_depths_p ())
              {
                int stack_depth = event.get_stack_depth ();
                /* -fdiagnostics-path-format=separate-events doesn't print
@@ -941,13 +940,13 @@ default_tree_diagnostic_path_printer (diagnostic_context *context,
       {
        /* Consolidate related events.  */
        path_summary summary (*path, true,
-                             context->m_source_printing.show_event_links_p);
-       char *saved_prefix = pp_take_prefix (context->printer);
-       pp_set_prefix (context->printer, NULL);
-       print_path_summary_as_text (&summary, context,
-                                   context->show_path_depths_p ());
-       pp_flush (context->printer);
-       pp_set_prefix (context->printer, saved_prefix);
+                             m_source_printing.show_event_links_p);
+       char *saved_prefix = pp_take_prefix (this->printer);
+       pp_set_prefix (this->printer, NULL);
+       print_path_summary_as_text (&summary, this,
+                                   show_path_depths_p ());
+       pp_flush (this->printer);
+       pp_set_prefix (this->printer, saved_prefix);
       }
       break;
     }
index f236f3db0b2d3f56686c5d4a679b14d5cd72ea3a..fc78231dfa4482ed530d1aa186ffe56ff5be993d 100644 (file)
@@ -179,7 +179,6 @@ tree_diagnostics_defaults (diagnostic_context *context)
   diagnostic_starter (context) = default_tree_diagnostic_starter;
   diagnostic_finalizer (context) = default_diagnostic_finalizer;
   diagnostic_format_decoder (context) = default_tree_printer;
-  context->m_print_path = default_tree_diagnostic_path_printer;
   context->set_set_locations_callback (set_inlining_locations);
   context->set_client_data_hooks (make_compiler_data_hooks ());
 }
index 648d6e6ab91699d23a857bd91ca902e760a71619..6ebac381ace8d80824bea02a775657a5b8c2e6fa 100644 (file)
@@ -55,7 +55,4 @@ void tree_diagnostics_defaults (diagnostic_context *context);
 bool default_tree_printer (pretty_printer *, text_info *, const char *,
                           int, bool, bool, bool, bool *, const char **);
 
-extern void default_tree_diagnostic_path_printer (diagnostic_context *,
-                                                 const diagnostic_path *);
-
 #endif /* ! GCC_TREE_DIAGNOSTIC_H */