From 5edb251951a3a250b54a22fbd24c4f65f19f76fb Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 8 Aug 2025 16:55:43 -0400 Subject: diagnostics: introduce struct column_options Consolidate 3 fields in diagnostics::context and diagnostics::column_policy into a new struct diagnostics::column_options. No functional change intended; reduces the number of public fields in diagnostics::context. gcc/c-family/ChangeLog: * c-indentation.cc (should_warn_for_misleading_indentation): Update for moving diagnostics::context::m_tabstop into diagnostics::column_options. * c-opts.cc (c_common_post_options): Likewise. gcc/ChangeLog: * diagnostics/column-options.h: New file, adding struct diagnostics::column_options, taken from fields in diagnostics::context and diagnostics::column_policy. * diagnostics/context.cc (context::initialize): Update for moving fields of diagnostics::context into diagnostics::column_options. (column_policy::column_policy): Likewise. (column_policy::converted_column): Move implementation to... (column_options::convert_column): ...this new function. (context::report_diagnostic): Update for moving fields of diagnostics::context into diagnostics::column_options. (assert_location_text): Likewise. * diagnostics/context.h: Include "diagnostics/column-options.h". (class column_policy): Replace fields m_column_unit, m_column_origin, and m_tabstop with m_column_options. (context::get_column_options): New accessors. (context::m_column_unit): Move to struct column_options and replace with m_column_options. (context::m_column_origin): Likewise. (context::m_tabstop): Likewise. * diagnostics/sarif-sink.cc (sarif_builder::sarif_builder): Update for moving fields of diagnostics::context into diagnostics::column_options. * diagnostics/source-printing.cc: Likewise. * opts.cc (common_handle_option): Likewise. Signed-off-by: David Malcolm --- gcc/c-family/c-indentation.cc | 2 +- gcc/c-family/c-opts.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/c-family') diff --git a/gcc/c-family/c-indentation.cc b/gcc/c-family/c-indentation.cc index bb214fc..d378464 100644 --- a/gcc/c-family/c-indentation.cc +++ b/gcc/c-family/c-indentation.cc @@ -330,7 +330,7 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo, if (guard_loc == body_loc || body_loc == next_stmt_loc) return false; - const unsigned int tab_width = global_dc->m_tabstop; + const unsigned int tab_width = global_dc->get_column_options ().m_tabstop; /* They must be in the same file. */ if (next_stmt_exploc.file != body_exploc.file) diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 3fb12b9..0ec30e8 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1200,7 +1200,7 @@ c_common_post_options (const char **pfilename) flag_char8_t = (cxx_dialect >= cxx20) || flag_isoc23; cpp_opts->unsigned_utf8char = flag_char8_t ? 1 : cpp_opts->unsigned_char; - cpp_opts->cpp_tabstop = global_dc->m_tabstop; + cpp_opts->cpp_tabstop = global_dc->get_column_options ().m_tabstop; if (flag_extern_tls_init) { -- cgit v1.1