aboutsummaryrefslogtreecommitdiff
path: root/gcc/diagnostic-format-json.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2023-11-14 14:02:10 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2023-11-14 14:02:10 -0500
commit353f146cebbf224520de1bdfa8e43ceba868cf62 (patch)
tree7a48c2ae51b0a964ce2348a4f99aa9c73717043a /gcc/diagnostic-format-json.cc
parent07e568d77f364e833193dd6f7b3170b28b1e52db (diff)
downloadgcc-353f146cebbf224520de1bdfa8e43ceba868cf62.zip
gcc-353f146cebbf224520de1bdfa8e43ceba868cf62.tar.gz
gcc-353f146cebbf224520de1bdfa8e43ceba868cf62.tar.bz2
diagnostics: make option-handling callbacks private
No functional change intended. gcc/c-family/ChangeLog: * c-warn.cc (conversion_warning): Update call to global_dc->m_option_enabled to use option_enabled_p. gcc/cp/ChangeLog: * decl.cc (finish_function): Update call to global_dc->m_option_enabled to use option_enabled_p. gcc/ChangeLog: * diagnostic-format-json.cc (json_output_format::on_end_diagnostic): Update calls to m_context callbacks to use member functions; tighten up scopes. * diagnostic-format-sarif.cc (sarif_builder::make_result_object): Likewise. (sarif_builder::make_reporting_descriptor_object_for_warning): Likewise. * diagnostic.cc (diagnostic_context::initialize): Update for callbacks being moved into m_option_callbacks and being renamed. (diagnostic_context::set_option_hooks): New. (diagnostic_option_classifier::classify_diagnostic): Update call to global_dc->m_option_enabled to use option_enabled_p. (diagnostic_context::print_option_information): Update calls to m_context callbacks to use member functions; tighten up scopes. (diagnostic_context::diagnostic_enabled): Likewise. * diagnostic.h (diagnostic_option_enabled_cb): New typedef. (diagnostic_make_option_name_cb): New typedef. (diagnostic_make_option_url_cb): New typedef. (diagnostic_context::option_enabled_p): New. (diagnostic_context::make_option_name): New. (diagnostic_context::make_option_url): New. (diagnostic_context::set_option_hooks): New decl. (diagnostic_context::m_option_enabled): Rename to m_option_enabled_cb and move within m_option_callbacks, using typedef. (diagnostic_context::m_option_state): Move within m_option_callbacks. (diagnostic_context::m_option_name): Rename to m_make_option_name_cb and move within m_option_callbacks, using typedef. (diagnostic_context::m_get_option_url): Likewise, renaming to m_make_option_url_cb. * lto-wrapper.cc (print_lto_docs_link): Update call to m_context callback to use member function. (main): Use diagnostic_context::set_option_hooks. * opts-diagnostic.h (option_name): Make context param const. (get_option_url): Likewise. * opts.cc (option_name): Likewise. (get_option_url): Likewise. * toplev.cc (general_init): Use diagnostic_context::set_option_hooks. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/diagnostic-format-json.cc')
-rw-r--r--gcc/diagnostic-format-json.cc18
1 files changed, 6 insertions, 12 deletions
diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc
index 7c5a126..141075b 100644
--- a/gcc/diagnostic-format-json.cc
+++ b/gcc/diagnostic-format-json.cc
@@ -217,24 +217,18 @@ json_output_format::on_end_diagnostic (diagnostic_info *diagnostic,
diag_obj->set_string ("message", pp_formatted_text (m_context.printer));
pp_clear_output_area (m_context.printer);
- char *option_text;
- option_text = m_context.m_option_name (&m_context, diagnostic->option_index,
- orig_diag_kind, diagnostic->kind);
- if (option_text)
+ if (char *option_text = m_context.make_option_name (diagnostic->option_index,
+ orig_diag_kind,
+ diagnostic->kind))
{
diag_obj->set_string ("option", option_text);
free (option_text);
}
- if (m_context.m_get_option_url)
+ if (char *option_url = m_context.make_option_url (diagnostic->option_index))
{
- char *option_url = m_context.m_get_option_url (&m_context,
- diagnostic->option_index);
- if (option_url)
- {
- diag_obj->set_string ("option_url", option_url);
- free (option_url);
- }
+ diag_obj->set_string ("option_url", option_url);
+ free (option_url);
}
/* If we've already emitted a diagnostic within this auto_diagnostic_group,