https://gcc.gnu.org/g:f14fee14d440cffa1eedaf5681602b446e263100
commit r16-3090-gf14fee14d440cffa1eedaf5681602b446e263100 Author: David Malcolm <dmalc...@redhat.com> Date: Fri Aug 8 16:55:45 2025 -0400 diagnostics: minor cleanups No functional change intended. gcc/ChangeLog: * diagnostic.h (diagnostics::get_cwe_url): Move decl to diagnostics/metadata.h. (diagnostics::maybe_line_and_column): Move into diagnostics::text_sink. * diagnostics/context.cc: Update for maybe_line_and_column becoming a static member of text_sink. * diagnostics/metadata.h (diagnostics::get_cwe_url): Move decl here from diagnostic.h. * diagnostics/text-sink.cc (maybe_line_and_column): Convert to... (text_sink::maybe_line_and_column): ...this. * diagnostics/text-sink.h (text_sink::maybe_line_and_column): Move here from diagnostic.h. Signed-off-by: David Malcolm <dmalc...@redhat.com> Diff: --- gcc/diagnostic.h | 3 --- gcc/diagnostics/context.cc | 6 +++--- gcc/diagnostics/metadata.h | 2 ++ gcc/diagnostics/text-sink.cc | 2 +- gcc/diagnostics/text-sink.h | 2 ++ 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 7572e044cadc..7d730461e241 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -277,9 +277,6 @@ namespace diagnostics { /* Compute the number of digits in the decimal representation of an integer. */ extern int num_digits (int); -extern char *get_cwe_url (int cwe); -extern const char *maybe_line_and_column (int line, int col); - } // namespace diagnostics #endif /* ! GCC_DIAGNOSTIC_H */ diff --git a/gcc/diagnostics/context.cc b/gcc/diagnostics/context.cc index a8ccbf60ded2..01599bc163d3 100644 --- a/gcc/diagnostics/context.cc +++ b/gcc/diagnostics/context.cc @@ -721,7 +721,7 @@ column_policy::get_location_text (const expanded_location &s, col = converted_column (s); } - const char *line_col = maybe_line_and_column (line, col); + const char *line_col = text_sink::maybe_line_and_column (line, col); return label_text::take (build_message_string ("%s%s%s:%s", locus_cs, file, line_col, locus_ce)); } @@ -2064,8 +2064,8 @@ test_get_location_text () assert_location_text ("foo.c:42:", "foo.c", 42, 10, false); assert_location_text ("foo.c:", "foo.c", 0, 10, false); - diagnostics::maybe_line_and_column (INT_MAX, INT_MAX); - diagnostics::maybe_line_and_column (INT_MIN, INT_MIN); + diagnostics::text_sink::maybe_line_and_column (INT_MAX, INT_MAX); + diagnostics::text_sink::maybe_line_and_column (INT_MIN, INT_MIN); { /* In order to test display columns vs byte columns, we need to create a diff --git a/gcc/diagnostics/metadata.h b/gcc/diagnostics/metadata.h index c28f9821ee8b..39291ec11ebe 100644 --- a/gcc/diagnostics/metadata.h +++ b/gcc/diagnostics/metadata.h @@ -119,6 +119,8 @@ class metadata const lazy_digraphs *m_lazy_digraphs; }; +extern char *get_cwe_url (int cwe); + } // namespace diagnostics #endif /* ! GCC_DIAGNOSTICS_METADATA_H */ diff --git a/gcc/diagnostics/text-sink.cc b/gcc/diagnostics/text-sink.cc index bcf91cf0f4ff..bf22a2c7da9a 100644 --- a/gcc/diagnostics/text-sink.cc +++ b/gcc/diagnostics/text-sink.cc @@ -612,7 +612,7 @@ text_sink::get_location_text (const expanded_location &s) const The result is a statically allocated buffer. */ const char * -maybe_line_and_column (int line, int col) +text_sink::maybe_line_and_column (int line, int col) { static char result[32]; diff --git a/gcc/diagnostics/text-sink.h b/gcc/diagnostics/text-sink.h index 5c60976641ef..bce3c039b715 100644 --- a/gcc/diagnostics/text-sink.h +++ b/gcc/diagnostics/text-sink.h @@ -127,6 +127,8 @@ public: return m_source_printing; } + static const char *maybe_line_and_column (int line, int col); + protected: void print_any_cwe (const diagnostic_info &diagnostic); void print_any_rules (const diagnostic_info &diagnostic);