Commit Graph

11 Commits

Author SHA1 Message Date
Jakub Jelinek
254a858ae7 Update copyright years. 2026-01-02 09:56:11 +01:00
David Malcolm
0558c6028e diagnostics: add class sink::extension
This patch provides a way for plugins to add extra information
to a diagnostic sink, potentially capturing more information via
a "finalizer" hook.

gcc/c-family/ChangeLog:
	* c-opts.cc: Define INCLUDE_VECTOR.

gcc/cp/ChangeLog:
	* error.cc: Define INCLUDE_VECTOR.

gcc/ChangeLog:
	* diagnostic-global-context.cc: Define INCLUDE_VECTOR.
	* diagnostics/buffering.cc: Likewise.
	* diagnostics/context.cc (context::finish): Call
	finalize_extensions on each sink.
	(sink::dump): Dump any extensions.
	(sink::finalize_extensions): New.
	* diagnostics/macro-unwinding.cc: Define INCLUDE_VECTOR.
	* diagnostics/selftest-context.cc: Likewise.
	* diagnostics/sink.h (class sink::extension): New.
	(sink::add_extension): New.
	(sink::finalize_extensions): New decl.
	(sink::m_extensions): New member.
	* gcc.cc: Define INCLUDE_VECTOR.
	* langhooks.cc: Likewise.
	* opts.cc: Likewise.
	* tree-diagnostic-client-data-hooks.cc: Likewise.
	* tree-diagnostic.cc: Likewise.

gcc/fortran/ChangeLog:
	* error.cc: Define INCLUDE_VECTOR.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic_group_plugin.cc: Define INCLUDE_VECTOR.
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
	* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

libcc1/ChangeLog:
	* context.cc: Define INCLUDE_VECTOR.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-10-09 11:38:50 -04:00
David Malcolm
24ffe3ea64 diagnostics: eliminate ::diagnostic_info typedef
No functional change intended.

gcc/c-family/ChangeLog:
	* c-common.cc: Update usage of "diagnostic_info" to explicitly
	refer to "diagnostics::diagnostic_info".
	* c-opts.cc: Likewise.

gcc/c/ChangeLog:
	* c-errors.cc: Update usage of "diagnostic_info" to explicitly
	refer to "diagnostics::diagnostic_info".

gcc/cp/ChangeLog:
	* constexpr.cc: Update usage of "diagnostic_info" to explicitly
	refer to "diagnostics::diagnostic_info".
	* cp-tree.h: Likewise.
	* error.cc: Likewise.
	* module.cc: Likewise.

gcc/d/ChangeLog:
	* d-diagnostic.cc: Likewise.

gcc/ChangeLog:
	* diagnostic.h: Eliminate "diagnostic_info" typedef.
	* diagnostics/context.cc: Update usage of "diagnostic_info" to
	explicitly refer to "diagnostics::diagnostic_info".
	* langhooks.cc: Likewise.
	* libgdiagnostics.cc: Likewise.
	* rtl-error.cc: Likewise.
	* substring-locations.cc: Likewise.
	* toplev.cc: Likewise.
	* tree-diagnostic.cc: Likewise.
	* tree-diagnostic.h: Likewise.

gcc/fortran/ChangeLog:
	* cpp.cc: Update usage of "diagnostic_info" to explicitly refer to
	"diagnostics::diagnostic_info".
	* error.cc: Likewise.

gcc/jit/ChangeLog:
	* dummy-frontend.cc: Update usage of "diagnostic_info" to
	explicitly refer to "diagnostics::diagnostic_info".

gcc/m2/ChangeLog:
	* gm2-gcc/m2linemap.cc: Update usage of "diagnostic_info" to
	explicitly refer to "diagnostics::diagnostic_info".
	* gm2-gcc/rtegraph.cc: Likewise.

gcc/rust/ChangeLog:
	* resolve/rust-ice-finalizer.cc: Update usage of "diagnostic_info"
	to explicitly refer to "diagnostics::diagnostic_info".
	* resolve/rust-ice-finalizer.h: Likewise.

gcc/testsuite/ChangeLog:
	* g++.dg/plugin/show_template_tree_color_plugin.cc: Update usage
	of "diagnostic_info" to explicitly refer to
	"diagnostics::diagnostic_info".
	* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
	* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

libcc1/ChangeLog:
	* context.cc: Update usage of "diagnostic_info" to explicitly
	refer to "diagnostics::diagnostic_info".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25 15:13:45 -04:00
David Malcolm
5ac3308484 diagnostics: move/rename output formats to diagnostics as "sinks"
Within gcc/
  move diagnostic-buffer.h to diagnostics/buffering.h
  move diagnostic-format-html.cc to diagnostics/html-sink.cc
  move diagnostic-format-html.h to diagnostics/html-sink.h
  move diagnostic-format-sarif.cc to diagnostics/sarif-sink.cc
  move diagnostic-format-sarif.h to diagnostics/sarif-sink.h
  move diagnostic-format.h to diagnostics/sink.h
  move diagnostic-format-text.cc to diagnostics/text-sink.cc
  move diagnostic-format-text.h to diagnostics/text-sink.h

renaming various types including:
  Old name:                       New name:
  diagnostic_output_format        diagnostics::sink
  diagnostic_buffer               diagnostics::buffer
  diagnostic_per_format_buffer    diagnostics::per_sink_buffer
  diagnostic_text_output_format   diagnostics::text_sink
  sarif_output_format             diagnostics::sarif_sink
  diagnostic_sarif_format_buffer  diagnostics::sarif_sink_buffer
  html_output_format              diagnostics::html_sink
  diagnostic_html_format_buffer   diagnostics::html_sink_buffer

No functional change intended.

gcc/ChangeLog:
	* Makefile.in (OBJS): Replace diagnostic-format-html.o with
	diagnostics/html-sink.o, diagnostic-format-sarif.o with
	diagnostics/sarif-sink.o, and diagnostic-format-text.o with
	diagnostics/text-sink.o.
	* coretypes.h (class diagnostic_text_output_format): Replace
	with...
	(class diagnostics::text_sink): ...this.
	* diagnostic-global-context.cc: Update for move of diagnostics
	output formats into namespace "diagnostics", as "sinks".
	* diagnostic-macro-unwinding.cc: Likewise.
	* diagnostic-macro-unwinding.h: Likewise.
	* diagnostic-show-locus.cc: Likewise.
	* diagnostic.cc: Likewise.
	* diagnostic.h: Likewise.
	* diagnostic-buffer.h: Rename to...
	* diagnostics/buffering.h: ...this, updating for above changes.
	* diagnostics/client-data-hooks.h: Likewise.
	* diagnostics/digraphs.cc: Likewise.
	* diagnostic-format-html.cc: Rename to...
	* diagnostics/html-sink.cc: ...this, updating for above changes.
	* diagnostic-format-html.h: Rename to...
	* diagnostics/html-sink.h: ...this, updating for above changes.
	* diagnostics/lazy-paths.cc: Likewise.
	* diagnostics/metadata.h: Likewise.
	* diagnostics/output-spec.cc: Likewise.
	* diagnostics/output-spec.h: Likewise.
	* diagnostics/paths-output.cc: Likewise.
	* diagnostics/paths.h: Likewise.
	* diagnostic-format-sarif.cc: Rename to...
	* diagnostics/sarif-sink.cc: ...this, updating for above changes.
	* diagnostic-format-sarif.h: Rename to...
	* diagnostics/sarif-sink.h: ...this, updating for above changes.
	* diagnostic-format.h: Rename to...
	* diagnostics/sink.h: ...this, updating for above changes.
	* diagnostics/state-graphs-to-dot.cc: Likewise.
	* diagnostic-format-text.cc: Rename to...
	* diagnostics/text-sink.cc: ...this, updating for above changes.
	* diagnostic-format-text.h: Rename to...
	* diagnostics/text-sink.h: ...this, updating for above changes.
	* gcc.cc: Likewise.
	* langhooks-def.h: Likewise.
	* langhooks.cc: Likewise.
	* langhooks.h: Likewise.
	* libgdiagnostics.cc: Likewise.
	* opts-diagnostic.cc: Likewise.
	* opts.cc: Likewise.
	* selftest-diagnostic.cc: Likewise.
	* selftest-run-tests.cc: Likewise.
	* selftest.h: Likewise.
	* tree-diagnostic-client-data-hooks.cc: Likewise.
	* tree-diagnostic.cc: Likewise.

gcc/analyzer/ChangeLog:
	* ana-state-to-diagnostic-state.cc: Update for move of
	diagnostics output formats into namespace "diagnostics" as
	"sinks".
	* bounds-checking.cc: Likewise.
	* call-details.cc: Likewise.
	* checker-event.cc: Likewise.
	* checker-event.h: Likewise.
	* diagnostic-manager.cc: Likewise.
	* diagnostic-manager.h: Likewise.
	* infinite-loop.cc: Likewise.
	* infinite-recursion.cc: Likewise.
	* pending-diagnostic.h: Likewise.
	* region-model.cc: Likewise.
	* sm-taint.cc: Likewise.

gcc/c-family/ChangeLog:
	* c-opts.cc: Update for move of diagnostics output formats into
	namespace "diagnostics" as "sinks".

gcc/cp/ChangeLog:
	* cp-tree.h: Update for move of diagnostics output formats into
	namespace "diagnostics" as "sinks".
	* error.cc: Likewise.

gcc/fortran/ChangeLog:
	* error.cc: Update for move of diagnostics output formats into
	namespace "diagnostics" as "sinks".
	* gfortran.h: Likewise.

gcc/jit/ChangeLog:
	* dummy-frontend.cc: Update for move of diagnostics output formats
	into namespace "diagnostics" as "sinks".

gcc/rust/ChangeLog:
	* resolve/rust-ice-finalizer.cc: Update for move of diagnostics
	output formats into namespace "diagnostics" as "sinks".
	* resolve/rust-ice-finalizer.h: Likewise.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic_group_plugin.cc: Update for move of
	diagnostics output formats into namespace "diagnostics" as
	"sinks".
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
	* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

libcc1/ChangeLog:
	* context.cc: Update for move of diagnostics output formats into
	namespace "diagnostics" as "sinks".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25 15:13:37 -04:00
Jakub Jelinek
6441eb6dc0 Update copyright years. 2025-01-02 11:59:57 +01:00
David Malcolm
7da682c896 diagnostics: convert text hooks to use diagnostic_text_output_format [PR116613]
The diagnostic_starter and diagnostic_finalizer callbacks and most of
their support subroutines are only used by the "text" output format.

Emphasize this and reduce the binding with diagnostic_context
by renaming the callbacks to add "_text" in their names, and converting
the first param from diagnostic_context * to
diagnostic_text_output_output &.  Update the various subroutines used
by diagnostic starter/finalizer callbacks to also take a
diagnostic_text_output_output & rather than a diagnostic_context *.
Move m_includes and m_last_seen from the context to the text output.

Use the text_output's get_printer () rather than the context's
m_printer, which should ease the transition to multiple output sinks.

No functional change intended.

gcc/c-family/ChangeLog:
	PR other/116613
	* c-opts.cc: Include "diagnostic-format-text.h".
	(c_diagnostic_finalizer): Rename to...
	(c_diagnostic_text_finalizer): ...this.  Convert first param
	from diagnostic_context * to diagnostic_text_output_format & and
	update accordingly.
	(c_common_diagnostics_set_defaults): Update for renamings.

gcc/ChangeLog:
	PR other/116613
	* coretypes.h (class diagnostic_text_output_format): Add forward
	decl.
	* diagnostic-format-json.cc
	(json_output_format::after_diagnostic): New.
	* diagnostic-format-sarif.cc
	(sarif_output_format::after_diagnostic): New.
	* diagnostic-format-text.cc: Use pragmas to ignore -Wformat-diag.
	(diagnostic_text_output_format::~diagnostic_text_output_format):
	Use get_printer.  Clean up m_includes_seen here, rather than
	in ~diagnostic_context.
	(diagnostic_text_output_format::on_report_diagnostic):  Use
	get_printer.  Update for callback renamings and pass *this
	to them, rather than &m_context.
	(diagnostic_text_output_format::after_diagnostic): New.
	(diagnostic_text_output_format::includes_seen_p): Move here
	from diagnostic_context/diagnostic.cc.
	(diagnostic_text_output_format::get_location_text): New.
	(maybe_line_and_column): Move here from diagnostic.cc and make
	non-static.
	(diagnostic_text_output_format::report_current_module): Move
	here from diagnostic_context/diagnostic.cc.
	(default_diagnostic_text_starter): Move here from diagnostic.cc,
	renaming from default_diagnostic_starter.
	(default_diagnostic_text_finalizer): Likewise, renaming from
	default_diagnostic_finalizer.
	* diagnostic-format-text.h
	(diagnostic_text_output_format::diagnostic_text_output_format):
	Initialize m_last_module and m_includes_seen.
	(diagnostic_text_output_format::after_diagnostic): New decl.
	(diagnostic_text_output_format::build_prefix): New decl.
	(diagnostic_text_output_format::report_current_module): New decl.
	(diagnostic_text_output_format::append_note): New decl.
	(diagnostic_text_output_format::file_name_as_prefix): New decl.
	(diagnostic_text_output_format::print_path): New decl.
	(diagnostic_text_output_format::show_column_p): New decl.
	(diagnostic_text_output_format::get_location_text): New decl.
	(diagnostic_text_output_format::includes_seen_p): New decl.
	(diagnostic_text_output_format::show_any_path): New decl.
	(diagnostic_text_output_format::m_last_module): New field.
	(diagnostic_text_output_format::m_includes_seen): New field.
	* diagnostic-format.h
	(diagnostic_output_format::after_diagnostic): New vfunc.
	(diagnostic_output_format::get_context): New.
	(diagnostic_output_format::get_diagram_theme): New.
	* diagnostic-macro-unwinding.cc: Include
	"diagnostic-format-text.h".
	(maybe_unwind_expanded_macro_loc): Convert first param from
	diagnostic_context * to diagnostic_text_output_format & and update
	accordingly.
	(virt_loc_aware_diagnostic_finalizer): Likewise.
	* diagnostic-macro-unwinding.h
	(virt_loc_aware_diagnostic_finalizer): Likewise.
	(maybe_unwind_expanded_macro_loc): Likewise.
	* diagnostic-path.cc: Include "diagnostic-format-text.h".
	(path_label::path_label): Drop "ctxt" param and add "colorize"
	and "allow_emojis" params.  Update initializations.
	(path_label::get_text): Use m_colorize rather than querying
	m_ctxt.m_printer.  Use m_allow_emojis rather than querying
	m_ctxt's diagram theme.
	(path_label::m_ctxt): Drop field.
	(path_label::m_colorize): Drop field.
	(path_label::m_allow_emojis): Drop field.
	(event_range::event_range): Drop param "ctxt".  Add params
	"colorize_labels" and "allow_emojis".
	(event_range::print): Convert first param from
	diagnostic_context & to diagnostic_text_output_format & and update
	accordingly.
	(path_summary::path_summary): Likewise.
	(path_summary::print_swimlane_for_event_range): Likewise.
	(print_path_summary_as_text): Likewise for 3rd param.
	(diagnostic_context::print_path): Convert to...
	(diagnostic_text_output_format::print_path): ...this.
	(selftest::test_empty_path): Update to use a
	diagnostic_text_output_format.
	(selftest::test_intraprocedural_path): Likewise.
	(selftest::test_interprocedural_path_1): Likewise.
	(selftest::test_interprocedural_path_2): Likewise.
	(selftest::test_recursion): Likewise.
	(selftest::test_control_flow_1): Likewise.
	(selftest::test_control_flow_2): Likewise.
	(selftest::test_control_flow_3): Likewise.
	(selftest::assert_cfg_edge_path_streq): Likewise.
	(selftest::test_control_flow_5): Likewise.
	(selftest::test_control_flow_6): Likewise.
	* diagnostic.cc (file_name_as_prefix): Convert to...
	(diagnostic_text_output_format::file_name_as_prefix): ...this.
	(diagnostic_context::initialize): Update for renamings.
	Move m_last_module and m_includes_seen into text output.
	(diagnostic_context::finish): Likewise.
	(diagnostic_context::get_location_text): Add "colorize" param.
	(diagnostic_build_prefix): Convert to...
	(diagnostic_text_output_format::build_prefix): ...this.
	(diagnostic_context::includes_seen_p): Move from here to
	diagnostic_text_output_format/diagnostic-format-text.cc.
	(diagnostic_context::report_current_module): Likewise.
	(diagnostic_context::show_any_path): Convert to...
	(diagnostic_text_output_format::show_any_path): ...this.
	(default_diagnostic_starter): Rename and move to
	diagnostic-format-text.cc.
	(default_diagnostic_start_span_fn): Pass colorize bool
	to get_location_text.
	(default_diagnostic_finalizer): Rename and move to
	diagnostic-format-text.cc.
	(diagnostic_context::report_diagnostic): Replace call to
	show_any_path with call to new output format "after_diagnostic"
	vfunc, moving show_any_path call to the text output format.
	(diagnostic_append_note): Convert to...
	(diagnostic_text_output_format::append_note): ...this.
	(selftest::assert_location_text): Pass in false for colorization.
	* diagnostic.h (diagnostic_starter_fn): Rename to...
	(diagnostic_text_starter_fn): ...this.  Convert first param from
	diagnostic_context * to diagnostic_text_output_format &.
	(diagnostic_finalizer_fn, diagnostic_text_finalizer_fn): Likewise.
	(diagnostic_context): Update friends for renamings.
	(diagnostic_context::report_current_module): Move to text output
	format.
	(diagnostic_context::get_location_text): Add "colorize" bool.
	(diagnostic_context::includes_seen_p): Move to text output format.
	(diagnostic_context::show_any_path): Likewise.
	(diagnostic_context::print_path): Likewise.
	(diagnostic_context::m_text_callbacks): Update for renamings.
	(diagnostic_context::m_last_module): Move to text output format.
	(diagnostic_context::m_includes_seen): Likewise.
	(diagnostic_starter): Rename to...
	(diagnostic_text_starter): ...this and update return type.
	(diagnostic_finalizer): Rename to...
	(diagnostic_text_finalizer): ...this and update return type.
	(diagnostic_report_current_module): Drop decl in favor of a member
	function of diagnostic_text_output_format.
	(diagnostic_append_note): Likewise.
	(default_diagnostic_starter): Rename to...
	(default_diagnostic_text_starter): ...this, updating type.
	(default_diagnostic_finalizer): Rename to...
	(default_diagnostic_text_finalizer): ...this, updating type.
	(file_name_as_prefix): Drop decl.
	* langhooks-def.h (lhd_print_error_function): Convert first param
	from diagnostic_context * to diagnostic_text_output_format &.
	* langhooks.cc: Include "diagnostic-format-text.h".
	(lhd_print_error_function): Likewise.  Update accordingly
	* langhooks.h (lang_hooks::print_error_function): Convert first
	param from diagnostic_context * to
	diagnostic_text_output_format &.
	* tree-diagnostic.cc: Include "diagnostic-format-text.h".
	(diagnostic_report_current_function): Convert first param from
	diagnostic_context * to diagnostic_text_output_format & and update
	accordingly.
	(default_tree_diagnostic_starter): Rename to...
	(default_tree_diagnostic_text_starter): ...this.  Convert first
	param from diagnostic_context * to diagnostic_text_output_format &
	and update accordingly.
	(tree_diagnostics_defaults): Update for renamings.

gcc/cp/ChangeLog:
	PR other/116613
	* cp-tree.h (cxx_print_error_function): Convert first param
	from diagnostic_context * to diagnostic_text_output_format &.
	* error.cc: Include "diagnostic-format-text.h".
	(cxx_initialize_diagnostics): Update for renamings.
	(cxx_print_error_function): Convert first param from
	diagnostic_context * to diagnostic_text_output_format & and update
	accordingly
	(cp_diagnostic_starter): Rename to...
	(cp_diagnostic_text_starter): ...this.  Convert first
	param from diagnostic_context * to diagnostic_text_output_format &
	and update accordingly.
	(cp_print_error_function): Likewise.
	(print_instantiation_full_context): Likewise.
	(print_instantiation_partial_context_line): Likewise.
	(print_instantiation_partial_context): Likewise.
	(maybe_print_instantiation_context): Likewise.
	(maybe_print_constexpr_context): Likewise.
	(print_location): Likewise.
	(print_constrained_decl_info): Likewise.
	(print_concept_check_info): Likewise.
	(print_constraint_context_head): Likewise.
	(print_requires_expression_info): Likewise.
	(maybe_print_single_constraint_context): Likewise.

gcc/fortran/ChangeLog:
	PR other/116613
	* error.cc: Include "diagnostic-format-text.h".
	(gfc_diagnostic_starter): Rename to...
	(gfc_diagnostic_text_starter): ...this.  Convert first
	param from diagnostic_context * to diagnostic_text_output_format &
	and update accordingly.
	(gfc_diagnostic_finalizer, gfc_diagnostic_text_finalizer):
	Likewise.
	(gfc_diagnostics_init): Update for renamings.
	(gfc_diagnostics_finish): Likewise.

gcc/jit/ChangeLog:
	PR other/116613
	* dummy-frontend.cc: Include "diagnostic-format-text.h".
	(jit_begin_diagnostic): Convert first param from
	diagnostic_context * to diagnostic_text_output_format &
	(jit_end_diagnostic): Likewise.  Update accordingly.
	(jit_langhook_init): Update for renamings.

gcc/rust/ChangeLog:
	PR other/116613
	* resolve/rust-ast-resolve-expr.cc
	(funny_ice_finalizer): : Convert first param from
	diagnostic_context * to diagnostic_text_output_format &.
	(ResolveExpr::visit): Update for renaming.

gcc/testsuite/ChangeLog:
	PR other/116613
	* g++.dg/plugin/show_template_tree_color_plugin.c
	(noop_starter_fn): Rename to...
	(noop_text_starter_fn): ...this.  Update first param from dc to
	text_output.
	(plugin_init): Update for renamings.
	* gcc.dg/plugin/diagnostic_group_plugin.c
	(test_diagnostic_starter): Rename to...
	(test_diagnostic_text_starter): ...this.  Update first param from
	dc to text_output.
	(plugin_init): Update for renaming.
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Include
	"diagnostic-format-text.h".
	(custom_diagnostic_finalizer): Rename to...
	(custom_diagnostic_text_finalizer): ...this.  Update first param
	from dc to text_output.
	(test_show_locus): Update for renamings.
	* gcc.dg/plugin/location_overflow_plugin.c: Include
	"diagnostic-format-text.h".
	(original_finalizer): Rename to...
	(original_text_finalizer): ...this and update type.
	(verify_unpacked_ranges): Update first param from dc to
	text_output.  Update for this and for renamings.
	(verify_no_columns): Likewise.
	(plugin_init): Update for renamings.

libcc1/ChangeLog:
	PR other/116613
	* context.cc: Include "diagnostic-format-text.h".
	(plugin_print_error_function): Update first param from
	diagnostic_context * to diagnostic_text_output_format &.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-20 18:51:55 -04:00
Jakub Jelinek
a945c346f5 Update copyright years. 2024-01-03 12:19:35 +01:00
David Malcolm
8fc4e6c397 diagnostics: use const and references for diagnostic_info
No functional change intended.

gcc/c-family/ChangeLog:
	* c-opts.cc (c_diagnostic_finalizer): Make "diagnostic" param
	const.

gcc/cp/ChangeLog:
	* cp-tree.h (cxx_print_error_function): Make diagnostic_info param
	const.
	* error.cc (cxx_print_error_function): Likewise.
	(cp_diagnostic_starter): Likewise.
	(cp_print_error_function): Likewise.

gcc/ChangeLog:
	* diagnostic-format-json.cc (on_begin_diagnostic): Convert param
	to const reference.
	(on_end_diagnostic): Likewise.
	(json_output_format::on_end_diagnostic): Likewise.
	* diagnostic-format-sarif.cc
	(sarif_invocation::add_notification_for_ice): Likewise.
	(sarif_result::on_nested_diagnostic): Likewise.
	(sarif_ice_notification::sarif_ice_notification): Likewise.
	(sarif_builder::end_diagnostic): Likewise.
	(sarif_builder::make_result_object): Likewise.
	(make_reporting_descriptor_object_for_warning): Likewise.
	(sarif_builder::make_locations_arr): Likewise.
	(sarif_output_format::on_begin_diagnostic): Likewise.
	(sarif_output_format::on_end_diagnostic): Likewise.
	* diagnostic.cc (default_diagnostic_starter): Make diagnostic_info
	param const.
	(default_diagnostic_finalizer): Likewise.
	(diagnostic_context::report_diagnostic): Pass diagnostic by
	reference to on_{begin,end}_diagnostic.
	(diagnostic_text_output_format::on_begin_diagnostic): Convert
	param to const reference.
	(diagnostic_text_output_format::on_end_diagnostic): Likewise.
	* diagnostic.h (diagnostic_starter_fn): Make diagnostic_info param
	const.
	(diagnostic_finalizer_fn): Likeewise.
	(diagnostic_output_format::on_begin_diagnostic): Convert param to
	const reference.
	(diagnostic_output_format::on_end_diagnostic): Likewise.
	(diagnostic_text_output_format::on_begin_diagnostic): Likewise.
	(diagnostic_text_output_format::on_end_diagnostic): Likewise.
	(default_diagnostic_starter): Make diagnostic_info param const.
	(default_diagnostic_finalizer): Likewise.
	* langhooks-def.h (lhd_print_error_function): Make diagnostic_info
	param const.
	* langhooks.cc (lhd_print_error_function): Likewise.
	* langhooks.h (lang_hooks::print_error_function): Likewise.
	* tree-diagnostic.cc (diagnostic_report_current_function):
	Likewise.
	(default_tree_diagnostic_starter): Likewise.
	(virt_loc_aware_diagnostic_finalizer): Likewise.
	* tree-diagnostic.h (diagnostic_report_current_function):
	Likewise.
	(virt_loc_aware_diagnostic_finalizer): Likewise.

gcc/fortran/ChangeLog:
	* error.cc (gfc_diagnostic_starter): Make diagnostic_info param
	const.
	(gfc_diagnostic_finalizer): Likewise.

gcc/jit/ChangeLog:
	* dummy-frontend.cc (jit_begin_diagnostic): Make diagnostic_info
	param const.
	(jit_end_diagnostic): Likewise.  Pass to add_diagnostic by
	reference.
	* jit-playback.cc (jit::playback::context::add_diagnostic):
	Convert diagnostic_info to const reference.
	* jit-playback.h (jit::playback::context::add_diagnostic):
	Likewise.

gcc/testsuite/ChangeLog:
	* g++.dg/plugin/show_template_tree_color_plugin.c
	(noop_starter_fn): Make diagnostic_info param const.
	* gcc.dg/plugin/diagnostic_group_plugin.c
	(test_diagnostic_starter): Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
	(custom_diagnostic_finalizer): Likewise.
	* gcc.dg/plugin/location_overflow_plugin.c
	(verify_unpacked_ranges): Likewise.
	(verify_no_columns): Likewise.

libcc1/ChangeLog:
	* context.cc (plugin_print_error_function): Make diagnostic_info
	param const.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-12-06 12:35:08 -05:00
Jakub Jelinek
83ffe9cde7 Update copyright years. 2023-01-16 11:52:17 +01:00
Jakub Jelinek
7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Tom Tromey
0624823260 libcc1: share basic context code
Both plugins in libcc1 share a fair amount of boilerplate.  They both
share error-emission code, context management code, and tree GC code.
This patch unifies these two bodies of code, avoiding needless
duplication.

libcc1

	* libcc1plugin.cc: Move code to context.cc.
	* libcp1plugin.cc: Move code to context.cc.
	* context.hh: New file.
	* context.cc: New file.
	* Makefile.in: Rebuild.
	* Makefile.am (AM_CPPFLAGS): Add more gcc flags.
	(CPPFLAGS_FOR_C, CPPFLAGS_FOR_CXX): Update.
	(libcc1plugin_la_SOURCES): Add context.hh, context.cc.
	(libcp1plugin_la_SOURCES): Likewise.
2021-05-05 00:06:17 -06:00