]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: move diagnostic_diagram to diagnostics::diagram
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 25 Jul 2025 19:13:35 +0000 (15:13 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 25 Jul 2025 19:13:35 +0000 (15:13 -0400)
No functional change intended.

gcc/analyzer/ChangeLog:
* bounds-checking.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for
move of diagnostic_diagram to diagnostics::diagram.

gcc/ChangeLog:
* diagnostic-format-html.cc: Update for move of diagnostic_diagram
to diagnostics::diagram.
* diagnostic-format-sarif.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for move
of diagnostic_diagram to diagnostics::diagram.
* diagnostic-format-text.cc: Likewise.
* diagnostic-format-text.h: Update for move of diagnostic_diagram
to diagnostics::diagram.
* diagnostic-format.h: Likewise.
* diagnostic.cc: Update #include for move of
"diagnostic-diagram.h" to "diagnostics/diagram.h". Update for move
of diagnostic_diagram to diagnostics::diagram.
* diagnostic.h: Update for move of diagnostic_diagram to
diagnostics::diagram.
* diagnostic-diagram.h: Move to...
* diagnostics/diagram.h: ...here.
(class diagnostic_diagram): Convert to...
(class diagnostics::diagram): ...this.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_text_art.cc: Update
#include for move of "diagnostic-diagram.h" to
"diagnostics/diagram.h". Update for move of diagnostic_diagram to
diagnostics::diagram.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/bounds-checking.cc
gcc/diagnostic-format-html.cc
gcc/diagnostic-format-sarif.cc
gcc/diagnostic-format-text.cc
gcc/diagnostic-format-text.h
gcc/diagnostic-format.h
gcc/diagnostic.cc
gcc/diagnostic.h
gcc/diagnostics/diagram.h [moved from gcc/diagnostic-diagram.h with 83% similarity]
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_text_art.cc

index d2e2b34e285008a98937c22c1efc330f15997b31..732c05ddb25be6aecc65d9c96425b7e3f2bef6ec 100644 (file)
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "analyzer/common.h"
 
 #include "intl.h"
-#include "diagnostic-diagram.h"
+#include "diagnostics/diagram.h"
 #include "diagnostic-format-sarif.h"
 
 #include "analyzer/analyzer-logging.h"
@@ -181,7 +181,7 @@ protected:
               a problem.  Give up if that's happened.  */
            return;
          }
-       diagnostic_diagram diagram
+       diagnostics::diagram diagram
          (canvas,
           /* Alt text.  */
           _("Diagram visualizing the predicted out-of-bounds access"));
index ceca1612fd61eb58a221a67d4a3bfda3e651b7c6..33dca5c0147cf5667842635594fb85c4efac7131 100644 (file)
@@ -122,7 +122,7 @@ public:
   void on_report_diagnostic (const diagnostic_info &diagnostic,
                             diagnostic_t orig_diag_kind,
                             diagnostic_html_format_buffer *buffer);
-  void emit_diagram (const diagnostic_diagram &diagram);
+  void emit_diagram (const diagram &d);
   void emit_global_graph (const digraphs::lazy_digraph &);
 
   void end_group ();
@@ -1240,7 +1240,7 @@ html_builder::make_element_for_metadata (const metadata &m)
    for HTML output.  */
 
 void
-html_builder::emit_diagram (const diagnostic_diagram &/*diagram*/)
+html_builder::emit_diagram (const diagram &)
 {
   /* We must be within the emission of a top-level diagnostic.  */
   gcc_assert (m_cur_diagnostic_element);
@@ -1364,9 +1364,9 @@ public:
   {
     m_builder.on_report_diagnostic (diagnostic, orig_diag_kind, m_buffer);
   }
-  void on_diagram (const diagnostic_diagram &diagram) final override
+  void on_diagram (const diagram &d) final override
   {
-    m_builder.emit_diagram (diagram);
+    m_builder.emit_diagram (d);
   }
   void after_diagnostic (const diagnostic_info &) final override
   {
index 44d94c758836a8b0f2afe137b0d75c3897487e4b..5663e778f155e53021a1430b1254310fc18024b3 100644 (file)
@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cpplib.h"
 #include "diagnostics/logical-locations.h"
 #include "diagnostic-client-data-hooks.h"
-#include "diagnostic-diagram.h"
+#include "diagnostics/diagram.h"
 #include "text-art/canvas.h"
 #include "diagnostic-format-sarif.h"
 #include "diagnostic-format-text.h"
@@ -454,7 +454,7 @@ public:
   on_nested_diagnostic (const diagnostic_info &diagnostic,
                        diagnostic_t orig_diag_kind,
                        sarif_builder &builder);
-  void on_diagram (const diagnostic_diagram &diagram,
+  void on_diagram (const diagram &d,
                   sarif_builder &builder);
 
 private:
@@ -777,7 +777,7 @@ public:
   void on_report_diagnostic (const diagnostic_info &diagnostic,
                             diagnostic_t orig_diag_kind,
                             diagnostic_sarif_format_buffer *buffer);
-  void emit_diagram (const diagnostic_diagram &diagram);
+  void emit_diagram (const diagram &d);
   void end_group ();
 
   void
@@ -807,7 +807,7 @@ public:
   std::unique_ptr<sarif_message>
   make_message_object (const char *msg) const;
   std::unique_ptr<sarif_message>
-  make_message_object_for_diagram (const diagnostic_diagram &diagram);
+  make_message_object_for_diagram (const diagram &d);
   std::unique_ptr<sarif_artifact_content>
   maybe_make_artifact_content_object (const char *filename) const;
 
@@ -1338,11 +1338,11 @@ sarif_result::on_nested_diagnostic (const diagnostic_info &diagnostic,
    (SARIF v2.1.0 section 3.28.5).  */
 
 void
-sarif_result::on_diagram (const diagnostic_diagram &diagram,
+sarif_result::on_diagram (const diagram &d,
                          sarif_builder &builder)
 {
   auto location_obj = std::make_unique<sarif_location> ();
-  auto message_obj = builder.make_message_object_for_diagram (diagram);
+  auto message_obj = builder.make_message_object_for_diagram (d);
   location_obj->set<sarif_message> ("message", std::move (message_obj));
 
   add_related_location (std::move (location_obj), builder);
@@ -1887,11 +1887,11 @@ sarif_builder::on_report_diagnostic (const diagnostic_info &diagnostic,
    for SARIF output.  */
 
 void
-sarif_builder::emit_diagram (const diagnostic_diagram &diagram)
+sarif_builder::emit_diagram (const diagram &d)
 {
   /* We must be within the emission of a top-level diagnostic.  */
   gcc_assert (m_cur_group_result);
-  m_cur_group_result->on_diagram (diagram, *this);
+  m_cur_group_result->on_diagram (d, *this);
 }
 
 /* Implementation of "end_group_cb" for SARIF output.  */
@@ -3249,18 +3249,18 @@ sarif_builder::make_message_object (const char *msg) const
   return message_obj;
 }
 
-/* Make a "message" object (SARIF v2.1.0 section 3.11) for DIAGRAM.
+/* Make a "message" object (SARIF v2.1.0 section 3.11) for D.
    We emit the diagram as a code block within the Markdown part
    of the message.  */
 
 std::unique_ptr<sarif_message>
-sarif_builder::make_message_object_for_diagram (const diagnostic_diagram &diagram)
+sarif_builder::make_message_object_for_diagram (const diagram &d)
 {
   auto message_obj = std::make_unique<sarif_message> ();
 
   /* "text" property (SARIF v2.1.0 section 3.11.8).  */
   set_string_property_escaping_braces (*message_obj,
-                                      "text", diagram.get_alt_text ());
+                                      "text", d.get_alt_text ());
 
   pretty_printer *const pp = m_printer;
   char *saved_prefix = pp_take_prefix (pp);
@@ -3269,7 +3269,7 @@ sarif_builder::make_message_object_for_diagram (const diagnostic_diagram &diagra
   /* "To produce a code block in Markdown, simply indent every line of
      the block by at least 4 spaces or 1 tab."
      Here we use 4 spaces.  */
-  diagram.get_canvas ().print_to_pp (pp, "    ");
+  d.get_canvas ().print_to_pp (pp, "    ");
   pp_set_prefix (pp, saved_prefix);
 
   /* "markdown" property (SARIF v2.1.0 section 3.11.9).  */
@@ -3915,9 +3915,9 @@ public:
   {
     m_builder.on_report_diagnostic (diagnostic, orig_diag_kind, m_buffer);
   }
-  void on_diagram (const diagnostic_diagram &diagram) final override
+  void on_diagram (const diagnostics::diagram &d) final override
   {
-    m_builder.emit_diagram (diagram);
+    m_builder.emit_diagram (d);
   }
   void after_diagnostic (const diagnostic_info &) final override
   {
index 0696a349b51cd6466fb515bcf57fb8adfe3fb290..5df117d40ce53176d15f821a9f0830d2c383a6b9 100644 (file)
@@ -30,7 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/metadata.h"
 #include "diagnostic-path.h"
 #include "diagnostic-client-data-hooks.h"
-#include "diagnostic-diagram.h"
+#include "diagnostics/diagram.h"
 #include "diagnostic-format-text.h"
 #include "diagnostic-buffer.h"
 #include "text-art/theme.h"
@@ -258,7 +258,7 @@ diagnostic_text_output_format::on_report_verbatim (text_info &text)
 }
 
 void
-diagnostic_text_output_format::on_diagram (const diagnostic_diagram &diagram)
+diagnostic_text_output_format::on_diagram (const diagnostics::diagram &d)
 {
   pretty_printer *const pp = get_printer ();
 
@@ -267,7 +267,7 @@ diagnostic_text_output_format::on_diagram (const diagnostic_diagram &diagram)
   /* Use a newline before and after and a two-space indent
      to make the diagram stand out a little from the wall of text.  */
   pp_newline (pp);
-  diagram.get_canvas ().print_to_pp (pp, "  ");
+  d.get_canvas ().print_to_pp (pp, "  ");
   pp_newline (pp);
   pp_set_prefix (pp, saved_prefix);
   pp_flush (pp);
index 64a4452e6ca9231a6c6617fc5849dbb391f4881a..bcaabf874fbd6c1e20136523a74d3dcfa46a9215 100644 (file)
@@ -60,7 +60,7 @@ public:
   void on_report_diagnostic (const diagnostic_info &,
                             diagnostic_t orig_diag_kind) override;
   void on_report_verbatim (text_info &) final override;
-  void on_diagram (const diagnostic_diagram &diagram) override;
+  void on_diagram (const diagnostics::diagram &d) override;
   void after_diagnostic (const diagnostic_info &) override;
   bool machine_readable_stderr_p () const final override
   {
index a4c776c30b0d5ce39dfb01ef0a2264a564b1cafc..113e7ba554a9a9dc4c5ea4fd6781c319589e35af 100644 (file)
@@ -61,7 +61,7 @@ public:
 
   virtual void on_report_verbatim (text_info &);
 
-  virtual void on_diagram (const diagnostic_diagram &diagram) = 0;
+  virtual void on_diagram (const diagnostics::diagram &diag) = 0;
   virtual void after_diagnostic (const diagnostic_info &) = 0;
   virtual bool machine_readable_stderr_p () const = 0;
   virtual bool follows_reference_printer_p () const = 0;
index 86bf4e3180a2a11df5c71ff55aa8f18fbfd1cdc8..09329f0712f6effaaf4937178bf9a9c4cfdc6818 100644 (file)
@@ -36,7 +36,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/metadata.h"
 #include "diagnostic-path.h"
 #include "diagnostic-client-data-hooks.h"
-#include "diagnostic-diagram.h"
+#include "diagnostics/diagram.h"
 #include "diagnostic-format.h"
 #include "diagnostic-format-sarif.h"
 #include "diagnostic-format-text.h"
@@ -1744,13 +1744,13 @@ diagnostic_context::diagnostic_n_impl (rich_location *richloc,
 /* Emit DIAGRAM to this context, respecting the output format.  */
 
 void
-diagnostic_context::emit_diagram (const diagnostic_diagram &diagram)
+diagnostic_context::emit_diagram (const diagnostics::diagram &diag)
 {
   if (m_diagrams.m_theme == nullptr)
     return;
 
   for (auto sink : m_output_sinks)
-    sink->on_diagram (diagram);
+    sink->on_diagram (diag);
 }
 
 /* Inform the user that an error occurred while trying to report some
index 70156fed236a58da43fd237ab70b818cd214dcd2..4ddc4b062d2ad055885705715ab11057d47c2fa1 100644 (file)
@@ -38,6 +38,8 @@ namespace diagnostics {
     class manager;
   } // namespace diagnostics::logical_locations
 
+  class diagram;
+
 } // namespace diagnostics
 
 namespace text_art
@@ -235,7 +237,6 @@ public:
 
 class edit_context;
 class diagnostic_client_data_hooks;
-class diagnostic_diagram;
 class diagnostic_source_effect_info;
 class diagnostic_output_format;
   class diagnostic_text_output_format;
@@ -666,7 +667,7 @@ public:
                                 diagnostic_source_effect_info *effect_info,
                                 html_label_writer *label_writer);
 
-  void emit_diagram (const diagnostic_diagram &diagram);
+  void emit_diagram (const diagnostics::diagram &diag);
 
   /* Various setters for use by option-handling logic.  */
   void set_output_format (std::unique_ptr<diagnostic_output_format> output_format);
similarity index 83%
rename from gcc/diagnostic-diagram.h
rename to gcc/diagnostics/diagram.h
index b1ff9a98f6a396df44f30bc6bcef2259ae348844..2d33b1058496e04cf5a092cebab10a4a4c19fb88 100644 (file)
@@ -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_DIAGRAM_H
-#define GCC_DIAGNOSTIC_DIAGRAM_H
+#ifndef GCC_DIAGNOSTICS_DIAGRAM_H
+#define GCC_DIAGNOSTICS_DIAGRAM_H
 
 namespace text_art
 {
   class canvas;
 } // namespace text_art
 
+namespace diagnostics {
+
 /* A text art diagram, along with an "alternative text" string
    describing it.  */
 
-class diagnostic_diagram
+class diagram
 {
  public:
-  diagnostic_diagram (const text_art::canvas &canvas,
-                     const char *alt_text)
+  diagram (const text_art::canvas &canvas,
+          const char *alt_text)
   : m_canvas (canvas),
     m_alt_text (alt_text)
   {
@@ -48,4 +50,6 @@ class diagnostic_diagram
   const char *const m_alt_text;
 };
 
-#endif /* ! GCC_DIAGNOSTIC_DIAGRAM_H */
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_DIAGRAM_H */
index e28d69758dae3825dcf0604562de3440faf9ac7e..ce2f1d3be43da297caa2a8fdade2640077a7ffa4 100644 (file)
@@ -9,7 +9,7 @@
 #include "coretypes.h"
 #include "plugin-version.h"
 #include "diagnostic.h"
-#include "diagnostic-diagram.h"
+#include "diagnostics/diagram.h"
 #include "text-art/canvas.h"
 #include "text-art/table.h"
 
@@ -22,7 +22,7 @@ using namespace text_art;
 static void
 emit_canvas (const canvas &c, const char *alt_text)
 {
-  diagnostic_diagram diagram (c, alt_text);
+  diagnostics::diagram diagram (c, alt_text);
   global_dc->emit_diagram (diagram);
 }