]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: minor cleanups
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 8 Aug 2025 20:55:45 +0000 (16:55 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 8 Aug 2025 20:55:45 +0000 (16:55 -0400)
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>
gcc/diagnostic.h
gcc/diagnostics/context.cc
gcc/diagnostics/metadata.h
gcc/diagnostics/text-sink.cc
gcc/diagnostics/text-sink.h

index 7572e044cadc9d6b1e510444f14127cc1a74520f..7d730461e241fce927842740bcee410c4023a0ab 100644 (file)
@@ -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 */
index a8ccbf60ded2a72766d21449777974c3017c9457..01599bc163d35305736b7b4f6479c2dbbd8cd01b 100644 (file)
@@ -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
index c28f9821ee8bf74295bd1902ef670cf6ee4efefd..39291ec11ebeea9ca83c9fb58e9e1cee158b70b6 100644 (file)
@@ -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 */
index bcf91cf0f4ff2293601bca5fb42fc737406cdc96..bf22a2c7da9ab4192203356ba48f0aaf04d0ba48 100644 (file)
@@ -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];
 
index 5c60976641efe8bf91e3c2a432280decf8607a0a..bce3c039b715436755987a145a39a08f464815c9 100644 (file)
@@ -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);