aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2025-08-08 16:55:45 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2025-08-08 16:55:45 -0400
commitf14fee14d440cffa1eedaf5681602b446e263100 (patch)
treead806ea10dceb0af95d7fba1803bb0ab4f26736b /gcc
parentd7d0ea918fad92aa6403b3d6998e81b45bc93ba5 (diff)
downloadgcc-f14fee14d440cffa1eedaf5681602b446e263100.zip
gcc-f14fee14d440cffa1eedaf5681602b446e263100.tar.gz
gcc-f14fee14d440cffa1eedaf5681602b446e263100.tar.bz2
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 <dmalcolm@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/diagnostic.h3
-rw-r--r--gcc/diagnostics/context.cc6
-rw-r--r--gcc/diagnostics/metadata.h2
-rw-r--r--gcc/diagnostics/text-sink.cc2
-rw-r--r--gcc/diagnostics/text-sink.h2
5 files changed, 8 insertions, 7 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 7572e04..7d73046 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 a8ccbf6..01599bc 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 c28f982..39291ec 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 bcf91cf..bf22a2c 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 5c60976..bce3c03 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);