diff options
author | David Malcolm <dmalcolm@redhat.com> | 2023-10-02 12:16:55 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2023-10-02 12:16:55 -0400 |
commit | c5c565eff6277ac176d6c5c94f55859d0eb28938 (patch) | |
tree | aebf4d02a7be6e413e14fa16afbbfd5a9f00742c /gcc/diagnostic.h | |
parent | c64693fb885f21fafa01d67c5d85e11942770a7c (diff) | |
download | gcc-upstream-c5c565eff6277ac176d6c5c94f55859d0eb28938.tar.gz |
diagnostics: group together source printing fields of diagnostic_context
struct diagnostic_context has > 60 fields.
Try to tame some of the complexity by grouping together the 8
source-printing fields into a struct, the "m_source_printing" field.
No functional change intended.
gcc/ada/ChangeLog:
* gcc-interface/misc.cc (gnat_post_options): Update for renaming
of diagnostic_context's show_caret to m_source_printing.enabled.
gcc/analyzer/ChangeLog:
* program-point.cc: Update for grouping of source printing fields
within diagnostic_context.
gcc/c-family/ChangeLog:
* c-common.cc (maybe_add_include_fixit): Update for renaming of
diagnostic_context's show_caret to m_source_printing.enabled.
* c-opts.cc (c_common_init_options): Update for renaming of
diagnostic_context's colorize_source_p to
m_source_printing.colorize_source_p.
gcc/ChangeLog:
* diagnostic-show-locus.cc: Update for reorganization of
source-printing fields of diagnostic_context.
* diagnostic.cc (diagnostic_set_caret_max_width): Likewise.
(diagnostic_initialize): Likewise.
* diagnostic.h (diagnostic_context::show_caret): Move to...
(diagnostic_context::m_source_printing::enabled): ...here.
(diagnostic_context::caret_max_width): Move to...
(diagnostic_context::m_source_printing::max_width): ...here.
(diagnostic_context::caret_chars): Move to...
(diagnostic_context::m_source_printing::caret_chars): ...here.
(diagnostic_context::colorize_source_p): Move to...
(diagnostic_context::m_source_printing::colorize_source_p): ...here.
(diagnostic_context::show_labels_p): Move to...
(diagnostic_context::m_source_printing::show_labels_p): ...here.
(diagnostic_context::show_line_numbers_p): Move to...
(diagnostic_context::m_source_printing::show_line_numbers_p): ...here.
(diagnostic_context::min_margin_width): Move to...
(diagnostic_context::m_source_printing::min_margin_width): ...here.
(diagnostic_context::show_ruler_p): Move to...
(diagnostic_context::m_source_printing::show_ruler_p): ...here.
(diagnostic_same_line): Update for above changes.
* opts.cc (common_handle_option): Update for reorganization of
source-printing fields of diagnostic_context.
* selftest-diagnostic.cc
(test_diagnostic_context::test_diagnostic_context): Likewise.
* toplev.cc (general_init): Likewise.
* tree-diagnostic-path.cc (struct event_range): Likewise.
gcc/fortran/ChangeLog:
* error.cc (gfc_diagnostic_starter): Update for reorganization of
source-printing fields of diagnostic_context.
(gfc_diagnostics_init): Likewise.
(gfc_diagnostics_finish): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_show_trees.c: Update for
reorganization of source-printing fields of diagnostic_context.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.c: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.c: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.c: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c:
Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/diagnostic.h')
-rw-r--r-- | gcc/diagnostic.h | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 4ec83a988d5..1f2d93c3d00 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -219,16 +219,6 @@ struct diagnostic_context int *push_list; int n_push; - /* True if we should print the source line with a caret indicating - the location. */ - bool show_caret; - - /* Maximum width of the source line printed. */ - int caret_max_width; - - /* Character used for caret diagnostics. */ - char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES]; - /* True if we should print any CWE identifiers associated with diagnostics. */ bool show_cwe; @@ -336,29 +326,49 @@ struct diagnostic_context bool inhibit_notes_p; - /* When printing source code, should the characters at carets and ranges - be colorized? (assuming colorization is on at all). - This should be true for frontends that generate range information - (so that the ranges of code are colorized), - and false for frontends that merely specify points within the - source code (to avoid e.g. colorizing just the first character in - a token, which would look strange). */ - bool colorize_source_p; + /* Fields relating to printing the user's source code (potentially with + a margin, underlining, labels, etc). */ + struct { + + /* True if we should print the source line with a caret indicating + the location. + Corresponds to -fdiagnostics-show-caret. */ + bool enabled; + + /* Maximum width of the source line printed. */ + int max_width; + + /* Character used at the caret when printing source locations. */ + char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES]; + + /* When printing source code, should the characters at carets and ranges + be colorized? (assuming colorization is on at all). + This should be true for frontends that generate range information + (so that the ranges of code are colorized), + and false for frontends that merely specify points within the + source code (to avoid e.g. colorizing just the first character in + a token, which would look strange). */ + bool colorize_source_p; + + /* When printing source code, should labelled ranges be printed? + Corresponds to -fdiagnostics-show-labels. */ + bool show_labels_p; - /* When printing source code, should labelled ranges be printed? */ - bool show_labels_p; + /* When printing source code, should there be a left-hand margin + showing line numbers? + Corresponds to -fdiagnostics-show-line-numbers. */ + bool show_line_numbers_p; - /* When printing source code, should there be a left-hand margin - showing line numbers? */ - bool show_line_numbers_p; + /* If printing source code, what should the minimum width of the margin + be? Line numbers will be right-aligned, and padded to this width. + Corresponds to -fdiagnostics-minimum-margin-width=VALUE. */ + int min_margin_width; - /* If printing source code, what should the minimum width of the margin - be? Line numbers will be right-aligned, and padded to this width. */ - int min_margin_width; + /* Usable by plugins; if true, print a debugging ruler above the + source output. */ + bool show_ruler_p; - /* Usable by plugins; if true, print a debugging ruler above the - source output. */ - bool show_ruler_p; + } m_source_printing; /* True if -freport-bug option is used. */ bool report_bug; @@ -605,8 +615,9 @@ inline bool diagnostic_same_line (const diagnostic_context *context, expanded_location s1, expanded_location s2) { - return s2.column && s1.line == s2.line - && context->caret_max_width - CARET_LINE_MARGIN > abs (s1.column - s2.column); + return (s2.column && s1.line == s2.line + && (context->m_source_printing.max_width - CARET_LINE_MARGIN + > abs (s1.column - s2.column))); } extern const char *diagnostic_get_color_for_kind (diagnostic_t kind); |