diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-05-28 15:55:28 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-05-28 16:01:52 -0400 |
commit | 21fc89bac61983a869c066f7377f8280a6adca49 (patch) | |
tree | 27e9ee4ac35c5479dec575e3fa30ddec11d760bf /libcpp | |
parent | 9bda2c4c81b668b1d9abbb58cc4e805ac955a639 (diff) | |
download | gcc-21fc89bac61983a869c066f7377f8280a6adca49.zip gcc-21fc89bac61983a869c066f7377f8280a6adca49.tar.gz gcc-21fc89bac61983a869c066f7377f8280a6adca49.tar.bz2 |
diagnostics: consolidate global state in diagnostic-color.cc
Simplify the table of default colors, avoiding the need to manually
add the strlen of each entry.
Consolidate the global state in diagnostic-color.cc into a
g_color_dict, adding selftests for the new class diagnostic_color_dict.
No functional change intended.
gcc/ChangeLog:
* diagnostic-color.cc: Define INCLUDE_VECTOR.
Include "label-text.h" and "selftest.h".
(struct color_cap): Replace with...
(struct color_default): ...this, adding "m_" prefixes to fields
and dropping "name_len" and "free_val" field.
(color_dict): Convert to...
(gcc_color_defaults): ...this, making const, dropping the trailing
strlen and "false" from each entry.
(class diagnostic_color_dict): New.
(g_color_dict): New.
(colorize_start): Reimplement in terms of g_color_dict.
(diagnostic_color_dict::get_entry_by_name): New, based on
colorize_start.
(diagnostic_color_dict::get_start_by_name): Likewise.
(diagnostic_color_dict::diagnostic_color_dict): New.
(parse_gcc_colors): Reimplement, moving body...
(diagnostic_color_dict::parse_envvar_value): ...here.
(colorize_init): Lazily create g_color_dict.
(selftest::test_empty_color_dict): New.
(selftest::test_default_color_dict): New.
(selftest::test_color_dict_envvar_parsing): New.
(selftest::diagnostic_color_cc_tests): New.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::diagnostic_color_cc_tests.
* selftest.h (selftest::diagnostic_color_cc_tests): New decl.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions