[6/7] diagnostics: eliminate diagnostic_context::m_print_path callback
Checks
Commit Message
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 | 4 ++--
gcc/diagnostic-format-sarif.cc | 4 +++-
gcc/diagnostic.cc | 3 +--
gcc/diagnostic.h | 4 ++--
gcc/tree-diagnostic-path.cc | 23 +++++++++++------------
gcc/tree-diagnostic.cc | 1 -
gcc/tree-diagnostic.h | 3 ---
7 files changed, 19 insertions(+), 23 deletions(-)
Comments
On Tue, 2024-06-18 at 11:08 -0400, David Malcolm wrote:
> No functional change intended.
Sorry, it looks like I should have combined patches 6 and 7, in that
patch 6 temporarily breaks the build:
e.g.:
https://builder.sourceware.org/buildbot/#/builders/156/builds/10063
make[2]: Leaving directory '/home/mjw/wildebeest/buildbot/gcc-fedora-ppc64le/gcc-build/gcc'
g++ -no-pie -g -O2 -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -no-pie gcov-dump.o \
hash-table.o ggc-none.o\
libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -o gcov-dump
/usr/bin/ld: libcommon.a(diagnostic.o): in function `diagnostic_context::show_any_path(diagnostic_info const&)':
/home/mjw/wildebeest/buildbot/gcc-fedora-ppc64le/gcc-build/gcc/../../gcc/gcc/diagnostic.cc:918:(.text+0x2084): undefined reference to `diagnostic_context::print_path(diagnostic_path const*)'
/usr/bin/ld: /home/mjw/wildebeest/buildbot/gcc-fedora-ppc64le/gcc-build/gcc/../../gcc/gcc/diagnostic.cc:918:(.text+0x4a34): undefined reference to `diagnostic_context::print_path(diagnostic_path const*)'
collect2: error: ld returned 1 exit status
Should be fixed by patch 7 in the kit, which puts that symbol in
libcommon.a; am continuing to watch the post-commit CI.
Sorry again
Dave
@@ -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);
@@ -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. */
@@ -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. */
@@ -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;
@@ -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;
}
@@ -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 ());
}
@@ -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 */