]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
json: move pp_markup::quoted_json_pointer to its own header
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 24 Feb 2026 22:41:17 +0000 (17:41 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 28 Apr 2026 23:11:23 +0000 (19:11 -0400)
gcc/ChangeLog:
* json-diagnostic.cc: Include "pretty-print-markup-json.h".
(class pp_markup::quoted_json_pointer): Move to...
* pretty-print-markup-json.h: ...this new file.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/json-diagnostic.cc
gcc/pretty-print-markup-json.h [new file with mode: 0644]

index bf61cd0007ecfb47eaab53b6b321150922d96899..fced0a48ecb5502c2a14d0b2fdfb5ed8ff600ac9 100644 (file)
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/text-sink.h"
 #include "diagnostics/physical-location-maker.h"
 #include "pretty-print-markup.h"
+#include "pretty-print-markup-json.h"
 
 static bool
 emit_json_diagnostic (gcc_json_context &ctxt,
@@ -184,32 +185,6 @@ private:
   const json::value &m_js_val;
 };
 
-namespace pp_markup {
-
-/* Print the JSON Pointer of a given json::value in quotes.  */
-
-class quoted_json_pointer : public pp_element
-{
-public:
-  quoted_json_pointer (const json::value &js_val)
-  : m_js_val (js_val)
-  {
-  }
-
-  void
-  add_to_phase_2 (context &ctxt) final override
-  {
-    ctxt.begin_quote ();
-    m_js_val.print_pointer (&ctxt.m_pp);
-    ctxt.end_quote ();
-  }
-
-private:
-  const json::value &m_js_val;
-};
-
-} // namespace pp_markup
-
 /* text_sink starter for diagnostics relating to JSON.  */
 
 static void
diff --git a/gcc/pretty-print-markup-json.h b/gcc/pretty-print-markup-json.h
new file mode 100644 (file)
index 0000000..d10e9fb
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright (C) 2026 Free Software Foundation, Inc.
+   Contributed by David Malcolm <dmalcolm@redhat.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+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_PRETTY_PRINT_MARKUP_JSON_H
+#define GCC_PRETTY_PRINT_MARKUP_JSON_H
+
+#include "pretty-print-markup.h"
+
+namespace pp_markup {
+
+/* Print the JSON Pointer of a given json::value in quotes.  */
+
+class quoted_json_pointer : public pp_element
+{
+public:
+  quoted_json_pointer (const json::value &js_val)
+  : m_js_val (js_val)
+  {
+  }
+
+  void
+  add_to_phase_2 (context &ctxt) final override
+  {
+   ctxt.begin_quote ();
+   m_js_val.print_pointer (&ctxt.m_pp);
+   ctxt.end_quote ();
+  }
+
+private:
+  const json::value &m_js_val;
+};
+
+} // namespace pp_markup
+
+#endif /* GCC_PRETTY_PRINT_MARKUP_JSON_H */