aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2023-11-03 21:46:47 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2023-11-03 21:46:47 -0400
commit8200cd97c9c57de582e81a68a6cb2046fa8decb2 (patch)
tree64e7d701ca299b60f0a33ca2d7b53fac08247605 /gcc/fortran
parent38904b732cdfb1a1f823ea81765a3975ee310e40 (diff)
downloadgcc-8200cd97c9c57de582e81a68a6cb2046fa8decb2.zip
gcc-8200cd97c9c57de582e81a68a6cb2046fa8decb2.tar.gz
gcc-8200cd97c9c57de582e81a68a6cb2046fa8decb2.tar.bz2
diagnostics: convert diagnostic_context to a class
This patch: - converts "struct diagnostic_context" to "class diagnostic_context". - ensures all data members have an "m_" prefix, except for "printer", which has so many uses that renaming would be painful. - makes most of the data members private - converts much of the diagnostic_* functions to member functions of diagnostic_context, adding compatibility wrappers for users such as the Fortran frontend, and making as many as possible private. No functional change intended. gcc/ChangeLog: * common.opt (fdiagnostics-text-art-charset=): Remove refererence to diagnostic-text-art.h. * coretypes.h (struct diagnostic_context): Replace forward decl with... (class diagnostic_context): ...this. * diagnostic-format-json.cc: Update for changes to diagnostic_context. * diagnostic-format-sarif.cc: Likewise. * diagnostic-show-locus.cc: Likewise. * diagnostic-text-art.h: Deleted file, moving content... (enum diagnostic_text_art_charset): ...to diagnostic.h, (DIAGNOSTICS_TEXT_ART_CHARSET_DEFAULT): ...deleting, (diagnostics_text_art_charset_init): ...deleting in favor of diagnostic_context::set_text_art_charset. * diagnostic.cc: Remove include of "diagnostic-text-art.h". (pedantic_warning_kind): Update for field renaming. (permissive_error_kind): Likewise. (permissive_error_option): Likewise. (diagnostic_initialize): Convert to... (diagnostic_context::initialize): ...this, updating for field renamings. (diagnostic_color_init): Convert to... (diagnostic_context::color_init): ...this. (diagnostic_urls_init): Convert to... (diagnostic_context::urls_init): ...this. (diagnostic_initialize_input_context): Convert to... (diagnostic_context::initialize_input_context): ...this. (diagnostic_finish): Convert to... (diagnostic_context::finish): ...this, updating for field renamings. (diagnostic_context::set_output_format): New. (diagnostic_context::set_client_data_hooks): New. (diagnostic_context::create_edit_context): New. (diagnostic_converted_column): Convert to... (diagnostic_context::converted_column): ...this. (diagnostic_get_location_text): Update for field renaming. (diagnostic_check_max_errors): Convert to... (diagnostic_context::check_max_errors): ...this, updating for field renamings. (diagnostic_action_after_output): Convert to... (diagnostic_context::action_after_output): ...this, updating for field renamings. (last_module_changed_p): Delete. (set_last_module): Delete. (includes_seen): Convert to... (diagnostic_context::includes_seen_p): ...this, updating for field renamings. (diagnostic_report_current_module): Convert to... (diagnostic_context::report_current_module): ...this, updating for field renamings, and replacing uses of last_module_changed_p and set_last_module to simple field accesses. (diagnostic_show_any_path): Convert to... (diagnostic_context::show_any_path): ...this. (diagnostic_classify_diagnostic): Convert to... (diagnostic_context::classify_diagnostic): ...this, updating for field renamings. (diagnostic_push_diagnostics): Convert to... (diagnostic_context::push_diagnostics): ...this, updating for field renamings. (diagnostic_pop_diagnostics): Convert to... (diagnostic_context::pop_diagnostics): ...this, updating for field renamings. (get_any_inlining_info): Convert to... (diagnostic_context::get_any_inlining_info): ...this, updating for field renamings. (update_effective_level_from_pragmas): Convert to... (diagnostic_context::update_effective_level_from_pragmas): ...this, updating for field renamings. (print_any_cwe): Convert to... (diagnostic_context::print_any_cwe): ...this. (print_any_rules): Convert to... (diagnostic_context::print_any_rules): ...this. (print_option_information): Convert to... (diagnostic_context::print_option_information): ...this, updating for field renamings. (diagnostic_enabled): Convert to... (diagnostic_context::diagnostic_enabled): ...this, updating for field renamings. (warning_enabled_at): Convert to... (diagnostic_context::warning_enabled_at): ...this. (diagnostic_report_diagnostic): Convert to... (diagnostic_context::report_diagnostic): ...this, updating for field renamings and conversions to member functions. (diagnostic_append_note): Update for field renaming. (diagnostic_impl): Use diagnostic_context::report_diagnostic directly. (diagnostic_n_impl): Likewise. (diagnostic_emit_diagram): Convert to... (diagnostic_context::emit_diagram): ...this, updating for field renamings. (error_recursion): Convert to... (diagnostic_context::error_recursion): ...this. (diagnostic_text_output_format::~diagnostic_text_output_format): Use accessor. (diagnostics_text_art_charset_init): Convert to... (diagnostic_context::set_text_art_charset): ...this. (assert_location_text): Update for field renamings. * diagnostic.h (enum diagnostic_text_art_charset): Move here from diagnostic-text-art.h. (struct diagnostic_context): Convert to... (class diagnostic_context): ...this. (diagnostic_context::ice_handler_callback_t): New typedef. (diagnostic_context::set_locations_callback_t): New typedef. (diagnostic_context::initialize): New decl. (diagnostic_context::color_init): New decl. (diagnostic_context::urls_init): New decl. (diagnostic_context::file_cache_init): New decl. (diagnostic_context::finish): New decl. (diagnostic_context::set_set_locations_callback): New. (diagnostic_context::initialize_input_context): New decl. (diagnostic_context::warning_enabled_at): New decl. (diagnostic_context::option_unspecified_p): New. (diagnostic_context::report_diagnostic): New decl. (diagnostic_context::report_current_module): New decl. (diagnostic_context::check_max_errors): New decl. (diagnostic_context::action_after_output): New decl. (diagnostic_context::classify_diagnostic): New decl. (diagnostic_context::push_diagnostics): New decl. (diagnostic_context::pop_diagnostics): New decl. (diagnostic_context::emit_diagram): New decl. (diagnostic_context::set_output_format): New decl. (diagnostic_context::set_text_art_charset): New decl. (diagnostic_context::set_client_data_hooks): New decl. (diagnostic_context::create_edit_context): New decl. (diagnostic_context::set_warning_as_error_requested): New. (diagnostic_context::set_report_bug): New. (diagnostic_context::set_extra_output_kind): New. (diagnostic_context::set_show_cwe): New. (diagnostic_context::set_show_rules): New. (diagnostic_context::set_path_format): New. (diagnostic_context::set_show_path_depths): New. (diagnostic_context::set_show_option_requested): New. (diagnostic_context::set_max_errors): New. (diagnostic_context::set_escape_format): New. (diagnostic_context::set_ice_handler_callback): New. (diagnostic_context::warning_as_error_requested_p): New. (diagnostic_context::show_path_depths_p): New. (diagnostic_context::get_path_format): New. (diagnostic_context::get_escape_format): New. (diagnostic_context::get_file_cache): New. (diagnostic_context::get_edit_context): New. (diagnostic_context::get_client_data_hooks): New. (diagnostic_context::get_diagram_theme): New. (diagnostic_context::converted_column): New decl. (diagnostic_context::diagnostic_count): New. (diagnostic_context::includes_seen_p): New decl. (diagnostic_context::print_any_cwe): New decl. (diagnostic_context::print_any_rules): New decl. (diagnostic_context::print_option_information): New decl. (diagnostic_context::show_any_path): New decl. (diagnostic_context::error_recursion): New decl. (diagnostic_context::diagnostic_enabled): New decl. (diagnostic_context::get_any_inlining_info): New decl. (diagnostic_context::update_effective_level_from_pragmas): New decl. (diagnostic_context::m_file_cache): Make private. (diagnostic_context::diagnostic_count): Rename to... (diagnostic_context::m_diagnostic_count): ...this and make private. (diagnostic_context::warning_as_error_requested): Rename to... (diagnostic_context::m_warning_as_error_requested): ...this and make private. (diagnostic_context::n_opts): Rename to... (diagnostic_context::m_n_opts): ...this and make private. (diagnostic_context::classify_diagnostic): Rename to... (diagnostic_context::m_classify_diagnostic): ...this and make private. (diagnostic_context::classification_history): Rename to... (diagnostic_context::m_classification_history): ...this and make private. (diagnostic_context::n_classification_history): Rename to... (diagnostic_context::m_n_classification_history): ...this and make private. (diagnostic_context::push_list): Rename to... (diagnostic_context::m_push_list): ...this and make private. (diagnostic_context::n_push): Rename to... (diagnostic_context::m_n_push): ...this and make private. (diagnostic_context::show_cwe): Rename to... (diagnostic_context::m_show_cwe): ...this and make private. (diagnostic_context::show_rules): Rename to... (diagnostic_context::m_show_rules): ...this and make private. (diagnostic_context::path_format): Rename to... (diagnostic_context::m_path_format): ...this and make private. (diagnostic_context::show_path_depths): Rename to... (diagnostic_context::m_show_path_depths): ...this and make private. (diagnostic_context::show_option_requested): Rename to... (diagnostic_context::m_show_option_requested): ...this and make private. (diagnostic_context::abort_on_error): Rename to... (diagnostic_context::m_abort_on_error): ...this. (diagnostic_context::show_column): Rename to... (diagnostic_context::m_show_column): ...this. (diagnostic_context::pedantic_errors): Rename to... (diagnostic_context::m_pedantic_errors): ...this. (diagnostic_context::permissive): Rename to... (diagnostic_context::m_permissive): ...this. (diagnostic_context::opt_permissive): Rename to... (diagnostic_context::m_opt_permissive): ...this. (diagnostic_context::fatal_errors): Rename to... (diagnostic_context::m_fatal_errors): ...this. (diagnostic_context::dc_inhibit_warnings): Rename to... (diagnostic_context::m_inhibit_warnings): ...this. (diagnostic_context::dc_warn_system_headers): Rename to... (diagnostic_context::m_warn_system_headers): ...this. (diagnostic_context::max_errors): Rename to... (diagnostic_context::m_max_errors): ...this and make private. (diagnostic_context::internal_error): Rename to... (diagnostic_context::m_internal_error): ...this. (diagnostic_context::option_enabled): Rename to... (diagnostic_context::m_option_enabled): ...this. (diagnostic_context::option_state): Rename to... (diagnostic_context::m_option_state): ...this. (diagnostic_context::option_name): Rename to... (diagnostic_context::m_option_name): ...this. (diagnostic_context::get_option_url): Rename to... (diagnostic_context::m_get_option_url): ...this. (diagnostic_context::print_path): Rename to... (diagnostic_context::m_print_path): ...this. (diagnostic_context::make_json_for_path): Rename to... (diagnostic_context::m_make_json_for_path): ...this. (diagnostic_context::x_data): Rename to... (diagnostic_context::m_client_aux_data): ...this. (diagnostic_context::last_location): Rename to... (diagnostic_context::m_last_location): ...this. (diagnostic_context::last_module): Rename to... (diagnostic_context::m_last_module): ...this and make private. (diagnostic_context::lock): Rename to... (diagnostic_context::m_lock): ...this and make private. (diagnostic_context::lang_mask): Rename to... (diagnostic_context::m_lang_mask): ...this. (diagnostic_context::inhibit_notes_p): Rename to... (diagnostic_context::m_inhibit_notes_p): ...this. (diagnostic_context::report_bug): Rename to... (diagnostic_context::m_report_bug): ...this and make private. (diagnostic_context::extra_output_kind): Rename to... (diagnostic_context::m_extra_output_kind): ...this and make private. (diagnostic_context::column_unit): Rename to... (diagnostic_context::m_column_unit): ...this and make private. (diagnostic_context::column_origin): Rename to... (diagnostic_context::m_column_origin): ...this and make private. (diagnostic_context::tabstop): Rename to... (diagnostic_context::m_tabstop): ...this and make private. (diagnostic_context::escape_format): Rename to... (diagnostic_context::m_escape_format): ...this and make private. (diagnostic_context::edit_context_ptr): Rename to... (diagnostic_context::m_edit_context_ptr): ...this and make private. (diagnostic_context::set_locations_cb): Rename to... (diagnostic_context::m_set_locations_cb): ...this and make private. (diagnostic_context::ice_handler_cb): Rename to... (diagnostic_context::m_ice_handler_cb): ...this and make private. (diagnostic_context::includes_seen): Rename to... (diagnostic_context::m_includes_seen): ...this and make private. (diagnostic_inhibit_notes): Update for field renaming. (diagnostic_context_auxiliary_data): Likewise. (diagnostic_abort_on_error): Convert from macro to inline function and update for field renaming. (diagnostic_kind_count): Convert from macro to inline function and use diagnostic_count accessor. (diagnostic_report_warnings_p): Update for field renaming. (diagnostic_initialize): Convert decl to inline function calling into diagnostic_context. (diagnostic_color_init): Likewise. (diagnostic_urls_init): Likewise. (diagnostic_urls_init): Likewise. (diagnostic_finish): Likewise. (diagnostic_report_current_module): Likewise. (diagnostic_show_any_path): Delete decl. (diagnostic_initialize_input_context): Convert decl to inline function calling into diagnostic_context. (diagnostic_classify_diagnostic): Likewise. (diagnostic_push_diagnostics): Likewise. (diagnostic_pop_diagnostics): Likewise. (diagnostic_report_diagnostic): Likewise. (diagnostic_action_after_output): Likewise. (diagnostic_check_max_errors): Likewise. (diagnostic_file_cache_fini): Delete decl. (diagnostic_converted_column): Delete decl. (warning_enabled_at): Convert decl to inline function calling into diagnostic_context. (option_unspecified_p): New. (diagnostic_emit_diagram): Delete decl. * gcc.cc: Remove include of "diagnostic-text-art.h". Update for changes to diagnostic_context. * input.cc (diagnostic_file_cache_init): Move implementation to... (diagnostic_context::file_cache_init): ...this new member function. (diagnostic_file_cache_fini): Delete. (diagnostics_file_cache_forcibly_evict_file): Update for m_file_cache becoming private. (location_get_source_line): Likewise. (get_source_file_content): Likewise. (location_missing_trailing_newline): Likewise. * input.h (diagnostics_file_cache_fini): Delete. * langhooks.cc: Update for changes to diagnostic_context. * lto-wrapper.cc: Likewise. * opts.cc: Remove include of "diagnostic-text-art.h". Update for changes to diagnostic_context. * selftest-diagnostic.cc: Update for changes to diagnostic_context. * toplev.cc: Likewise. * tree-diagnostic-path.cc: Likewise. * tree-diagnostic.cc: Likewise. gcc/ada/ChangeLog: * gcc-interface/misc.cc: Update for changes to diagnostic_context. gcc/analyzer/ChangeLog: * bounds-checking.cc: Update for changes to diagnostic_context. gcc/c-family/ChangeLog: * c-common.cc: Update for changes to diagnostic_context. * c-indentation.cc: Likewise. * c-opts.cc: Likewise. * c-warn.cc: Likewise. gcc/cp/ChangeLog: * call.cc: Update for changes to diagnostic_context. * class.cc: Likewise. * decl.cc: Likewise. * error.cc: Likewise. * except.cc: Likewise. * pt.cc: Likewise. gcc/fortran/ChangeLog: * cpp.cc: Update for changes to diagnostic_context. * error.cc: Likewise. * options.cc: Likewise. gcc/jit/ChangeLog: * jit-playback.cc: Update for changes to diagnostic_context. * jit-playback.h: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_group_plugin.c: Update for changes to diagnostic_context. * gcc.dg/plugin/diagnostic_plugin_test_text_art.c: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/cpp.cc6
-rw-r--r--gcc/fortran/error.cc26
-rw-r--r--gcc/fortran/options.cc3
3 files changed, 17 insertions, 18 deletions
diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc
index 67e4d4e..02c28a7 100644
--- a/gcc/fortran/cpp.cc
+++ b/gcc/fortran/cpp.cc
@@ -1084,13 +1084,13 @@ cb_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
{
diagnostic_info diagnostic;
diagnostic_t dlevel;
- bool save_warn_system_headers = global_dc->dc_warn_system_headers;
+ bool save_warn_system_headers = global_dc->m_warn_system_headers;
bool ret;
switch (level)
{
case CPP_DL_WARNING_SYSHDR:
- global_dc->dc_warn_system_headers = 1;
+ global_dc->m_warn_system_headers = 1;
/* Fall through. */
case CPP_DL_WARNING:
dlevel = DK_WARNING;
@@ -1119,7 +1119,7 @@ cb_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
cb_cpp_diagnostic_cpp_option (reason));
ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
if (level == CPP_DL_WARNING_SYSHDR)
- global_dc->dc_warn_system_headers = save_warn_system_headers;
+ global_dc->m_warn_system_headers = save_warn_system_headers;
return ret;
}
diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc
index 1b34619..ca31775 100644
--- a/gcc/fortran/error.cc
+++ b/gcc/fortran/error.cc
@@ -871,7 +871,7 @@ gfc_clear_pp_buffer (output_buffer *this_buffer)
pp->buffer = tmp_buffer;
/* We need to reset last_location, otherwise we may skip caret lines
when we actually give a diagnostic. */
- global_dc->last_location = UNKNOWN_LOCATION;
+ global_dc->m_last_location = UNKNOWN_LOCATION;
}
/* The currently-printing diagnostic, for use by gfc_format_decoder,
@@ -903,7 +903,7 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
diagnostic_info diagnostic;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
- bool fatal_errors = global_dc->fatal_errors;
+ bool fatal_errors = global_dc->m_fatal_errors;
pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer;
@@ -912,7 +912,7 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
if (buffered_p)
{
pp->buffer = pp_warning_buffer;
- global_dc->fatal_errors = false;
+ global_dc->m_fatal_errors = false;
/* To prevent -fmax-errors= triggering. */
--werrorcount;
}
@@ -925,7 +925,7 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
if (buffered_p)
{
pp->buffer = tmp_buffer;
- global_dc->fatal_errors = fatal_errors;
+ global_dc->m_fatal_errors = fatal_errors;
warningcount_buffered = 0;
werrorcount_buffered = 0;
@@ -1156,7 +1156,7 @@ gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
: !strcmp (s.file, special_fname_builtin ())
? build_message_string ("%s%s:%s", locus_cs, s.file, locus_ce)
- : context->show_column
+ : context->m_show_column
? build_message_string ("%s%s:%d:%d:%s", locus_cs, s.file, s.line,
s.column, locus_ce)
: build_message_string ("%s%s:%d:%s", locus_cs, s.file, s.line, locus_ce));
@@ -1176,7 +1176,7 @@ gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
: !strcmp (s.file, special_fname_builtin ())
? build_message_string ("%s%s:%s", locus_cs, s.file, locus_ce)
- : context->show_column
+ : context->m_show_column
? build_message_string ("%s%s:%d:%d-%d:%s", locus_cs, s.file, s.line,
MIN (s.column, s2.column),
MAX (s.column, s2.column), locus_ce)
@@ -1224,7 +1224,7 @@ gfc_diagnostic_starter (diagnostic_context *context,
if (!context->m_source_printing.enabled
|| diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
- || diagnostic_location (diagnostic, 0) == context->last_location)
+ || diagnostic_location (diagnostic, 0) == context->m_last_location)
{
pp_set_prefix (context->printer,
concat (locus_prefix, " ", kind_prefix, NULL));
@@ -1437,7 +1437,7 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap)
diagnostic_info diagnostic;
rich_location richloc (line_table, UNKNOWN_LOCATION);
- bool fatal_errors = global_dc->fatal_errors;
+ bool fatal_errors = global_dc->m_fatal_errors;
pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer;
@@ -1447,10 +1447,10 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap)
{
/* To prevent -dH from triggering an abort on a buffered error,
save abort_on_error and restore it below. */
- saved_abort_on_error = global_dc->abort_on_error;
- global_dc->abort_on_error = false;
+ saved_abort_on_error = global_dc->m_abort_on_error;
+ global_dc->m_abort_on_error = false;
pp->buffer = pp_error_buffer;
- global_dc->fatal_errors = false;
+ global_dc->m_fatal_errors = false;
/* To prevent -fmax-errors= triggering, we decrease it before
report_diagnostic increases it. */
--errorcount;
@@ -1462,8 +1462,8 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap)
if (buffered_p)
{
pp->buffer = tmp_buffer;
- global_dc->fatal_errors = fatal_errors;
- global_dc->abort_on_error = saved_abort_on_error;
+ global_dc->m_fatal_errors = fatal_errors;
+ global_dc->m_abort_on_error = saved_abort_on_error;
}
diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc
index 2ad2247..cfb1957 100644
--- a/gcc/fortran/options.cc
+++ b/gcc/fortran/options.cc
@@ -389,8 +389,7 @@ gfc_post_options (const char **pfilename)
/* Enable -Werror=line-truncation when -Werror and -Wno-error have
not been set. */
if (warn_line_truncation && !OPTION_SET_P (warnings_are_errors)
- && (global_dc->classify_diagnostic[OPT_Wline_truncation] ==
- DK_UNSPECIFIED))
+ && option_unspecified_p (OPT_Wline_truncation))
diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
DK_ERROR, UNKNOWN_LOCATION);
}