https://gcc.gnu.org/g:accd28c1aa02439901c05a9a41d9a3611978d809

commit r16-2526-gaccd28c1aa02439901c05a9a41d9a3611978d809
Author: David Malcolm <dmalc...@redhat.com>
Date:   Fri Jul 25 15:13:36 2025 -0400

    diagnostics: rename diagnostic_output_file to diagnostics::output_file
    
    No functional change intended.
    
    gcc/ChangeLog:
            * diagnostic-format-html.cc: Update #include for move of
            diagnostic-output-file.h to diagnostics/output-file.h.  Update for
            move of diagnostic_output_file to diagnostics::output_file.
            * diagnostic-format-html.h: Likewise.
            * diagnostic-format-sarif.cc: Likewise.
            * diagnostic-format-sarif.h: Likewise.
            * diagnostic-output-spec.cc: Likewise.
            * diagnostic-output-spec.h (along): Likewise.
            * diagnostic-output-file.h: Move to...
            * diagnostics/output-file.h: ...here, updating header guard.
            (class diagnostic_output_file): Move to...
            (class diagnostics::output_file): ...here.
            * libgdiagnostics.cc (sarif_sink::sarif_sink): Update for
            move of diagnostic_output_file to diagnostics::output_file.
    
    Signed-off-by: David Malcolm <dmalc...@redhat.com>

Diff:
---
 gcc/diagnostic-format-html.cc                      | 24 +++++-----
 gcc/diagnostic-format-html.h                       |  6 +--
 gcc/diagnostic-format-sarif.cc                     | 54 +++++++++++-----------
 gcc/diagnostic-format-sarif.h                      |  6 +--
 gcc/diagnostic-output-spec.cc                      | 10 ++--
 gcc/diagnostic-output-spec.h                       |  4 +-
 .../output-file.h}                                 | 32 +++++++------
 gcc/libgdiagnostics.cc                             |  4 +-
 8 files changed, 72 insertions(+), 68 deletions(-)

diff --git a/gcc/diagnostic-format-html.cc b/gcc/diagnostic-format-html.cc
index 90a2ee239de2..df0a32a81ac7 100644
--- a/gcc/diagnostic-format-html.cc
+++ b/gcc/diagnostic-format-html.cc
@@ -30,7 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic-format-html.h"
 #include "diagnostic-format-text.h"
 #include "diagnostic-format-sarif.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
 #include "diagnostic-buffer.h"
 #include "diagnostic-path.h"
 #include "diagnostics/client-data-hooks.h"
@@ -1422,9 +1422,9 @@ public:
   html_file_output_format (diagnostic_context &context,
                           const line_maps *line_maps,
                           const html_generation_options &html_gen_opts,
-                          diagnostic_output_file output_file)
+                          output_file output_file_)
   : html_output_format (context, line_maps, html_gen_opts),
-    m_output_file (std::move (output_file))
+    m_output_file (std::move (output_file_))
   {
     gcc_assert (m_output_file.get_open_file ());
     gcc_assert (m_output_file.get_filename ());
@@ -1446,15 +1446,15 @@ public:
   }
 
 private:
-  diagnostic_output_file m_output_file;
+  output_file m_output_file;
 };
 
 /* Attempt to open BASE_FILE_NAME.html for writing.
-   Return a non-null diagnostic_output_file,
-   or return a null diagnostic_output_file and complain to CONTEXT
+   Return a non-null output_file,
+   or return a null output_file and complain to CONTEXT
    using LINE_MAPS.  */
 
-diagnostic_output_file
+output_file
 diagnostic_output_format_open_html_file (diagnostic_context &context,
                                         line_maps *line_maps,
                                         const char *base_file_name)
@@ -1465,7 +1465,7 @@ diagnostic_output_format_open_html_file 
(diagnostic_context &context,
       context.emit_diagnostic_with_group
        (DK_ERROR, richloc, nullptr, 0,
         "unable to determine filename for HTML output");
-      return diagnostic_output_file ();
+      return output_file ();
     }
 
   label_text filename = label_text::take (concat (base_file_name,
@@ -1479,22 +1479,22 @@ diagnostic_output_format_open_html_file 
(diagnostic_context &context,
        (DK_ERROR, richloc, nullptr, 0,
         "unable to open %qs for HTML output: %m",
         filename.get ());
-      return diagnostic_output_file ();
+      return output_file ();
     }
-  return diagnostic_output_file (outf, true, std::move (filename));
+  return output_file (outf, true, std::move (filename));
 }
 
 std::unique_ptr<diagnostic_output_format>
 make_html_sink (diagnostic_context &context,
                const line_maps &line_maps,
                const html_generation_options &html_gen_opts,
-               diagnostic_output_file output_file)
+               output_file output_file_)
 {
   auto sink
     = std::make_unique<html_file_output_format> (context,
                                                 &line_maps,
                                                 html_gen_opts,
-                                                std::move (output_file));
+                                                std::move (output_file_));
   sink->update_printer ();
   return sink;
 }
diff --git a/gcc/diagnostic-format-html.h b/gcc/diagnostic-format-html.h
index 537ba54ddc52..d55cd301dc63 100644
--- a/gcc/diagnostic-format-html.h
+++ b/gcc/diagnostic-format-html.h
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #define GCC_DIAGNOSTIC_FORMAT_HTML_H
 
 #include "diagnostic-format.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
 
 struct html_generation_options
 {
@@ -43,7 +43,7 @@ struct html_generation_options
   bool m_show_state_diagrams_dot_src;
 };
 
-extern diagnostic_output_file
+extern diagnostics::output_file
 diagnostic_output_format_open_html_file (diagnostic_context &context,
                                         line_maps *line_maps,
                                         const char *base_file_name);
@@ -52,7 +52,7 @@ extern std::unique_ptr<diagnostic_output_format>
 make_html_sink (diagnostic_context &context,
                const line_maps &line_maps,
                const html_generation_options &html_gen_opts,
-               diagnostic_output_file output_file);
+               diagnostics::output_file output_file_);
 
 extern void
 print_path_as_html (xml::printer &xp,
diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index 75451cbf779a..4f1cd0bd4e0c 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -3916,7 +3916,7 @@ public:
   {
     m_builder.on_report_diagnostic (diagnostic, orig_diag_kind, m_buffer);
   }
-  void on_diagram (const diagnostics::diagram &d) final override
+  void on_diagram (const diagram &d) final override
   {
     m_builder.emit_diagram (d);
   }
@@ -3983,10 +3983,10 @@ public:
                            const line_maps *line_maps,
                            std::unique_ptr<sarif_serialization_format> 
serialization_format,
                            const sarif_generation_options &sarif_gen_opts,
-                           diagnostic_output_file output_file)
+                           output_file output_file_)
   : sarif_output_format (context, line_maps,
                         std::move (serialization_format), sarif_gen_opts),
-    m_output_file (std::move (output_file))
+    m_output_file (std::move (output_file_))
   {
     gcc_assert (m_output_file.get_open_file ());
     gcc_assert (m_output_file.get_filename ());
@@ -4008,7 +4008,7 @@ public:
   }
 
 private:
-  diagnostic_output_file m_output_file;
+  output_file m_output_file;
 };
 
 /* Print the start of an embedded link to PP, as per 3.11.6.  */
@@ -4167,16 +4167,16 @@ diagnostic_output_format_init_sarif_stderr 
(diagnostic_context &context,
 }
 
 /* Attempt to open "BASE_FILE_NAME""EXTENSION" for writing.
-   Return a non-null diagnostic_output_file,
-   or return a null diagnostic_output_file and complain to CONTEXT
+   Return a non-null output_file,
+   or return a null output_file and complain to CONTEXT
    using LINE_MAPS.  */
 
-diagnostic_output_file
-diagnostic_output_file::try_to_open (diagnostic_context &context,
-                                    line_maps *line_maps,
-                                    const char *base_file_name,
-                                    const char *extension,
-                                    bool is_binary)
+output_file
+output_file::try_to_open (diagnostic_context &context,
+                         line_maps *line_maps,
+                         const char *base_file_name,
+                         const char *extension,
+                         bool is_binary)
 {
   gcc_assert (extension);
   gcc_assert (extension[0] == '.');
@@ -4187,7 +4187,7 @@ diagnostic_output_file::try_to_open (diagnostic_context 
&context,
       context.emit_diagnostic_with_group
        (DK_ERROR, richloc, nullptr, 0,
         "unable to determine filename for SARIF output");
-      return diagnostic_output_file ();
+      return output_file ();
     }
 
   label_text filename = label_text::take (concat (base_file_name,
@@ -4201,17 +4201,17 @@ diagnostic_output_file::try_to_open (diagnostic_context 
&context,
        (DK_ERROR, richloc, nullptr, 0,
         "unable to open %qs for diagnostic output: %m",
         filename.get ());
-      return diagnostic_output_file ();
+      return output_file ();
     }
-  return diagnostic_output_file (outf, true, std::move (filename));
+  return output_file (outf, true, std::move (filename));
 }
 
 /* Attempt to open BASE_FILE_NAME.sarif for writing JSON.
-   Return a non-null diagnostic_output_file,
-   or return a null diagnostic_output_file and complain to CONTEXT
+   Return a non-null output_file,
+   or return a null output_file and complain to CONTEXT
    using LINE_MAPS.  */
 
-diagnostic_output_file
+output_file
 diagnostic_output_format_open_sarif_file (diagnostic_context &context,
                                          line_maps *line_maps,
                                          const char *base_file_name,
@@ -4229,11 +4229,11 @@ diagnostic_output_format_open_sarif_file 
(diagnostic_context &context,
       break;
     }
 
-  return diagnostic_output_file::try_to_open (context,
-                                             line_maps,
-                                             base_file_name,
-                                             suffix,
-                                             is_binary);
+  return output_file::try_to_open (context,
+                                  line_maps,
+                                  base_file_name,
+                                  suffix,
+                                  is_binary);
 }
 
 /* Populate CONTEXT in preparation for SARIF output to a file named
@@ -4248,7 +4248,7 @@ diagnostic_output_format_init_sarif_file 
(diagnostic_context &context,
 {
   gcc_assert (line_maps);
 
-  diagnostic_output_file output_file
+  output_file output_file_
     = diagnostic_output_format_open_sarif_file (context,
                                                line_maps,
                                                base_file_name,
@@ -4263,7 +4263,7 @@ diagnostic_output_format_init_sarif_file 
(diagnostic_context &context,
                                                 line_maps,
                                                 std::move (serialization),
                                                 sarif_gen_opts,
-                                                std::move (output_file)));
+                                                std::move (output_file_)));
 }
 
 /* Populate CONTEXT in preparation for SARIF output to STREAM.
@@ -4293,14 +4293,14 @@ make_sarif_sink (diagnostic_context &context,
                 const line_maps &line_maps,
                 std::unique_ptr<sarif_serialization_format> serialization,
                 const sarif_generation_options &sarif_gen_opts,
-                diagnostic_output_file output_file)
+                output_file output_file_)
 {
   auto sink
     = std::make_unique<sarif_file_output_format> (context,
                                                  &line_maps,
                                                  std::move (serialization),
                                                  sarif_gen_opts,
-                                                 std::move (output_file));
+                                                 std::move (output_file_));
   sink->update_printer ();
   return sink;
 }
diff --git a/gcc/diagnostic-format-sarif.h b/gcc/diagnostic-format-sarif.h
index 29ee9a84b554..b5efd7aab578 100644
--- a/gcc/diagnostic-format-sarif.h
+++ b/gcc/diagnostic-format-sarif.h
@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "json.h"
 #include "diagnostic-format.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
 #include "diagnostics/logical-locations.h"
 
 /* Enum for choosing what format to serializing the generated SARIF into.  */
@@ -35,7 +35,7 @@ enum class sarif_serialization_kind
    num_values
 };
 
-extern diagnostic_output_file
+extern diagnostics::output_file
 diagnostic_output_format_open_sarif_file (diagnostic_context &context,
                                          line_maps *line_maps,
                                          const char *base_file_name,
@@ -109,7 +109,7 @@ make_sarif_sink (diagnostic_context &context,
                 const line_maps &line_maps,
                 std::unique_ptr<sarif_serialization_format> 
serialization_format,
                 const sarif_generation_options &sarif_gen_opts,
-                diagnostic_output_file output_file);
+                diagnostics::output_file output_file_);
 
 class sarif_builder;
 class sarif_location_manager;
diff --git a/gcc/diagnostic-output-spec.cc b/gcc/diagnostic-output-spec.cc
index 4fa317628122..b028482c5e66 100644
--- a/gcc/diagnostic-output-spec.cc
+++ b/gcc/diagnostic-output-spec.cc
@@ -241,16 +241,16 @@ context::report_missing_key (const char *unparsed_arg,
      get_option_name (), scheme_name.c_str (), key.c_str (), metavar);
 }
 
-diagnostic_output_file
+diagnostics::output_file
 context::open_output_file (label_text &&filename) const
 {
   FILE *outf = fopen (filename.get (), "w");
   if (!outf)
     {
       report_error ("unable to open %qs: %m", filename.get ());
-      return diagnostic_output_file (nullptr, false, std::move (filename));
+      return diagnostics::output_file (nullptr, false, std::move (filename));
     }
-  return diagnostic_output_file (outf, true, std::move (filename));
+  return diagnostics::output_file (outf, true, std::move (filename));
 }
 
 static std::unique_ptr<scheme_name_and_params>
@@ -488,7 +488,7 @@ sarif_scheme_handler::make_sink (const context &ctxt,
       return nullptr;
     }
 
-  diagnostic_output_file output_file;
+  diagnostics::output_file output_file;
   if (filename.get ())
     output_file = ctxt.open_output_file (std::move (filename));
   else
@@ -621,7 +621,7 @@ html_scheme_handler::make_sink (const context &ctxt,
       return nullptr;
     }
 
-  diagnostic_output_file output_file;
+  diagnostics::output_file output_file;
   if (filename.get ())
     output_file = ctxt.open_output_file (std::move (filename));
   else
diff --git a/gcc/diagnostic-output-spec.h b/gcc/diagnostic-output-spec.h
index e02cdfe1705a..1ffe4a38b4fe 100644
--- a/gcc/diagnostic-output-spec.h
+++ b/gcc/diagnostic-output-spec.h
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #define GCC_DIAGNOSTIC_OUTPUT_SPEC_H
 
 #include "diagnostic-format.h"
-#include "diagnostic-output-file.h"
+#include "diagnostics/output-file.h"
 
 namespace diagnostics_output_spec {
 
@@ -52,7 +52,7 @@ class context
                      const std::string &scheme_name,
                      const char *metavar) const;
 
-  diagnostic_output_file
+  diagnostics::output_file
   open_output_file (label_text &&filename) const;
 
   const char *
diff --git a/gcc/diagnostic-output-file.h b/gcc/diagnostics/output-file.h
similarity index 78%
rename from gcc/diagnostic-output-file.h
rename to gcc/diagnostics/output-file.h
index a0b2e1bf4596..09df417e8a62 100644
--- a/gcc/diagnostic-output-file.h
+++ b/gcc/diagnostics/output-file.h
@@ -18,22 +18,24 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#ifndef GCC_DIAGNOSTIC_OUTPUT_FILE_H
-#define GCC_DIAGNOSTIC_OUTPUT_FILE_H
+#ifndef GCC_DIAGNOSTICS_OUTPUT_FILE_H
+#define GCC_DIAGNOSTICS_OUTPUT_FILE_H
+
+namespace diagnostics {
 
 /* RAII class for wrapping a FILE * that could be borrowed or owned,
    along with the underlying filename.  */
 
-class diagnostic_output_file
+class output_file
 {
 public:
-  diagnostic_output_file ()
+  output_file ()
   : m_outf (nullptr),
     m_owned (false),
     m_filename ()
   {
   }
-  diagnostic_output_file (FILE *outf, bool owned, label_text filename)
+  output_file (FILE *outf, bool owned, label_text filename)
   : m_outf (outf),
     m_owned (owned),
     m_filename (std::move (filename))
@@ -42,7 +44,7 @@ public:
     if (m_owned)
       gcc_assert (m_outf);
   }
-  ~diagnostic_output_file ()
+  ~output_file ()
   {
     if (m_owned)
       {
@@ -50,8 +52,8 @@ public:
        fclose (m_outf);
       }
   }
-  diagnostic_output_file (const diagnostic_output_file &other) = delete;
-  diagnostic_output_file (diagnostic_output_file &&other)
+  output_file (const output_file &other) = delete;
+  output_file (output_file &&other)
   : m_outf (other.m_outf),
     m_owned (other.m_owned),
     m_filename (std::move (other.m_filename))
@@ -63,10 +65,10 @@ public:
     if (m_owned)
       gcc_assert (m_outf);
   }
-  diagnostic_output_file &
-  operator= (const diagnostic_output_file &other) = delete;
-  diagnostic_output_file &
-  operator= (diagnostic_output_file &&other)
+  output_file &
+  operator= (const output_file &other) = delete;
+  output_file &
+  operator= (output_file &&other)
   {
     if (m_owned)
       {
@@ -91,7 +93,7 @@ public:
   FILE *get_open_file () const { return m_outf; }
   const char *get_filename () const { return m_filename.get (); }
 
-  static diagnostic_output_file
+  static output_file
   try_to_open (diagnostic_context &context,
               line_maps *line_maps,
               const char *base_file_name,
@@ -104,4 +106,6 @@ private:
   label_text m_filename;
 };
 
-#endif /* ! GCC_DIAGNOSTIC_OUTPUT_FILE_H */
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_OUTPUT_FILE_H */
diff --git a/gcc/libgdiagnostics.cc b/gcc/libgdiagnostics.cc
index 65bad53f254a..692fca7289a4 100644
--- a/gcc/libgdiagnostics.cc
+++ b/gcc/libgdiagnostics.cc
@@ -1518,8 +1518,8 @@ sarif_sink::sarif_sink (diagnostic_manager &mgr,
                        const sarif_generation_options &sarif_gen_opts)
 : sink (mgr)
 {
-  diagnostic_output_file output_file (dst_stream, false,
-                                     label_text::borrow ("sarif_sink"));
+  diagnostics::output_file output_file (dst_stream, false,
+                                       label_text::borrow ("sarif_sink"));
   auto serialization = std::make_unique<sarif_serialization_format_json> 
(true);
   auto inner_sink = make_sarif_sink (mgr.get_dc (),
                                     *mgr.get_line_table (),

Reply via email to