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

gcc/ada/ChangeLog:
* gcc-interface/misc.cc: Update for diagnostic_context becoming
diagnostics::context.

gcc/analyzer/ChangeLog:
* program-point.cc: : Update for diagnostic_context becoming
diagnostics::context, and for diagnostic_source_print_policy
becoming diagnostics::source_print_policy.

gcc/c-family/ChangeLog:
* c-common.h: Update for diagnostic_context becoming
diagnostics::context.
* c-opts.cc: Likewise.

gcc/c/ChangeLog:
* c-objc-common.cc: Update for diagnostic_context becoming
diagnostics::context.
* c-tree.h: Likewise.

gcc/ChangeLog:
* coretypes.h: Update for diagnostic_context becoming
diagnostics::context.
* diagnostic-global-context.cc: Likewise.
* diagnostic.cc: Likewise.  Also for diagnostic_option_classifier
becoming diagnostics::option_classifier.
* diagnostic.h (diagnostic_text_starter_fn): Rename to...
(diagnostics::text_starter_fn): ...this, and move to
diagnostics/context.h.
(get_printer): Rename to...
(diagnostics::get_printer): ...this, and move to
diagnostics/context.h.
(class diagnostic_option_manager): Rename to...
(class diagnostics::option_manager): ...this, and move to
diagnostics/context.h.
(class diagnostic_option_classifier): Rename to...
(class diagnostics::option_classifier): ...this, and move to
diagnostics/context.h.
(struct diagnostic_source_printing_options): Rename to...
(struct diagnostics::source_printing_options): ...this, and move
to diagnostics/context.h.
(class diagnostic_column_policy): Rename to...
(class diagnostics::column_policy): ...this, and move to
diagnostics/context.h.
(class diagnostic_location_print_policy): Rename to...
(class diagnostics::location_print_policy): ...this, and move to
diagnostics/context.h.
(class html_label_writer): Rename to...
(class diagnostics::html_label_writer): ...this, and move to
diagnostics/context.h.
(class diagnostic_source_print_policy): Rename to...
(class diagnostics::source_print_policy): ...this, and move to
diagnostics/context.h.
(struct diagnostic_counters): Rename to...
(struct diagnostics::counters): ...this, and move to
diagnostics/context.h.
(class diagnostic_context): Rename to...
(class diagnostics::context): ...this, and move to
diagnostics/context.h.
(diagnostic_text_starter): Rename to...
(diagnostics::text_starter): ...this, and move to
diagnostics/context.h.
(diagnostic_start_span): Rename to...
(diagnostics::start_span): ...this, and move to
diagnostics/context.h.
(diagnostic_text_finalizer): Rename to...
(diagnostics::text_finalizer): ...this, and move to
diagnostics/context.h.
Include "diagnostics/context.h".
* diagnostics/buffering.h: Update for diagnostic_context becoming
diagnostics::context; similarly for diagnostic_counters.
* diagnostics/client-data-hooks.h: Likewise.
* diagnostics/context.h: New file, taken from material in
diagnostic.h.
* diagnostics/html-sink.cc: : Update for diagnostic_context
becoming diagnostics::context.
* diagnostics/html-sink.h: Likewise.
* diagnostics/lazy-paths.cc: Likewise for
diagnostic_option_manager.
* diagnostics/output-file.h: Likewise for diagnostic_context.
* diagnostics/output-spec.cc: Likewise.
* diagnostics/output-spec.h: Likewise.
* diagnostics/paths-output.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/sarif-sink.h: Likewise.
* diagnostics/sink.h: Likewise.
* diagnostics/source-printing.cc: Likewise.
* diagnostics/text-sink.cc: Likewise.
* diagnostics/text-sink.h: Likewise.
* gcc-rich-location.h: Likewise.
* gcc.cc: Likewise.
* gdbinit.in: Likewise.
* langhooks-def.h: Likewise.
* langhooks.cc: Likewise.
* langhooks.h: Likewise.
* libgdiagnostics.cc: Likewise.
* optc-gen.awk: Likewise.
* opth-gen.awk: Likewise.
* opts-common.cc: Likewise.
* opts-diagnostic.cc: Likewise.
* opts-diagnostic.h: Likewise.
* opts-global.cc: Likewise.
* opts.cc: Likewise.
* opts.h: Likewise.
* selftest-diagnostic.cc: Likewise.
* selftest-diagnostic.h: Likewise.
* toplev.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.
* tree-diagnostic.h: Likewise.

gcc/cp/ChangeLog:
* cp-tree.h: Update for diagnostic_context becoming
diagnostics::context.
* error.cc: Likewise.
* module.cc: Likewise.

gcc/fortran/ChangeLog:
* error.cc: Update for diagnostic_context becoming
diagnostics::context.

gcc/jit/ChangeLog:
* dummy-frontend.cc: Update for diagnostic_context becoming
diagnostics::context.
* jit-playback.h: Likewise.

gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc: Update for diagnostic_text_finalizer
becoming diagnostics::text_finalizer.
* resolve/rust-late-name-resolver-2.0.cc: Likewise.

gcc/testsuite/ChangeLog:
* g++.dg/plugin/show_template_tree_color_plugin.cc: Update for
moves to namespace diagnostics.
* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
59 files changed:
gcc/ada/gcc-interface/misc.cc
gcc/analyzer/program-point.cc
gcc/c-family/c-common.h
gcc/c-family/c-opts.cc
gcc/c/c-objc-common.cc
gcc/c/c-tree.h
gcc/coretypes.h
gcc/cp/cp-tree.h
gcc/cp/error.cc
gcc/cp/module.cc
gcc/diagnostic-global-context.cc
gcc/diagnostic.cc
gcc/diagnostic.h
gcc/diagnostics/buffering.h
gcc/diagnostics/client-data-hooks.h
gcc/diagnostics/context.h [new file with mode: 0644]
gcc/diagnostics/html-sink.cc
gcc/diagnostics/html-sink.h
gcc/diagnostics/lazy-paths.cc
gcc/diagnostics/output-file.h
gcc/diagnostics/output-spec.cc
gcc/diagnostics/output-spec.h
gcc/diagnostics/paths-output.cc
gcc/diagnostics/sarif-sink.cc
gcc/diagnostics/sarif-sink.h
gcc/diagnostics/sink.h
gcc/diagnostics/source-printing.cc
gcc/diagnostics/text-sink.cc
gcc/diagnostics/text-sink.h
gcc/fortran/error.cc
gcc/gcc-rich-location.h
gcc/gcc.cc
gcc/gdbinit.in
gcc/jit/dummy-frontend.cc
gcc/jit/jit-playback.h
gcc/langhooks-def.h
gcc/langhooks.cc
gcc/langhooks.h
gcc/libgdiagnostics.cc
gcc/optc-gen.awk
gcc/opth-gen.awk
gcc/opts-common.cc
gcc/opts-diagnostic.cc
gcc/opts-diagnostic.h
gcc/opts-global.cc
gcc/opts.cc
gcc/opts.h
gcc/rust/resolve/rust-ast-resolve-expr.cc
gcc/rust/resolve/rust-late-name-resolver-2.0.cc
gcc/selftest-diagnostic.cc
gcc/selftest-diagnostic.h
gcc/testsuite/g++.dg/plugin/show_template_tree_color_plugin.cc
gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.cc
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc
gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc
gcc/toplev.cc
gcc/tree-diagnostic-client-data-hooks.cc
gcc/tree-diagnostic.cc
gcc/tree-diagnostic.h

index 128040e4d90d3f93dd3a8289df0278cb3e83c7b3..6de9b42dc9b1cf24aa57bcea8f9545e5886bfa1d 100644 (file)
@@ -292,7 +292,7 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
 /* Here is the function to handle the compiler error processing in GCC.  */
 
 static void
-internal_error_function (diagnostic_context *context, const char *msgid,
+internal_error_function (diagnostics::context *context, const char *msgid,
                         va_list *ap)
 {
   char *buffer, *p, *loc;
index 30468d768b09ed7afeeb08762bf8223e3eae6e7f..1d5d65c5cc403b523a82ee3aab1082557f9ea3a3 100644 (file)
@@ -234,10 +234,10 @@ function_point::before_supernode (const supernode *supernode,
   return function_point (supernode, from_edge, 0, PK_BEFORE_SUPERNODE);
 }
 
-/* A subclass of diagnostic_context for use by
+/* A subclass of diagnostics::context for use by
    program_point::print_source_line.  */
 
-class debug_diagnostic_context : public diagnostic_context
+class debug_diagnostic_context : public diagnostics::context
 {
 public:
   debug_diagnostic_context ()
@@ -263,7 +263,7 @@ function_point::print_source_line (pretty_printer *pp) const
   // TODO: monospace font
   debug_diagnostic_context tmp_dc;
   gcc_rich_location richloc (stmt->location);
-  diagnostic_source_print_policy source_policy (tmp_dc);
+  diagnostics::source_print_policy source_policy (tmp_dc);
   gcc_assert (pp);
   source_policy.print (*pp, richloc, DK_ERROR, nullptr);
   pp_string (pp, pp_formatted_text (tmp_dc.get_reference_printer ()));
index 675708d2680f3492c34765617666f1bafe3022e4..40b97e2d90e4aebce561034678ceb9a248e14ded 100644 (file)
@@ -979,7 +979,7 @@ extern tree build_va_arg (location_t, tree, tree);
 
 extern const unsigned int c_family_lang_mask;
 extern unsigned int c_common_option_lang_mask (void);
-extern void c_common_diagnostics_set_defaults (diagnostic_context *);
+extern void c_common_diagnostics_set_defaults (diagnostics::context *);
 extern bool c_common_complain_wrong_lang_p (const struct cl_option *);
 extern void c_common_init_options_struct (struct gcc_options *);
 extern void c_common_init_options (unsigned int, struct cl_decoded_option *);
index 88353062db47f8545159e4504c8c4a211beb393a..05985ea084af9e047c616177a6a9f4eb47434701 100644 (file)
@@ -189,9 +189,9 @@ c_diagnostic_text_finalizer (diagnostics::text_sink &text_output,
 
 /* Common default settings for diagnostics.  */
 void
-c_common_diagnostics_set_defaults (diagnostic_context *context)
+c_common_diagnostics_set_defaults (diagnostics::context *context)
 {
-  diagnostic_text_finalizer (context) = c_diagnostic_text_finalizer;
+  diagnostics::text_finalizer (context) = c_diagnostic_text_finalizer;
   context->set_permissive_option (OPT_fpermissive);
 }
 
index d574bc77128912204ea485c9199372a40ff9809a..5c50983544d7f0dd13f74e203b46061a8829e4f2 100644 (file)
@@ -414,7 +414,7 @@ has_c_linkage (const_tree decl ATTRIBUTE_UNUSED)
 }
 
 void
-c_initialize_diagnostics (diagnostic_context *context)
+c_initialize_diagnostics (diagnostics::context *context)
 {
   context->set_pretty_printer (std::make_unique<c_pretty_printer> ());
   c_common_diagnostics_set_defaults (context);
index 364f51df58c9ee1d4434fb20cbcd0f7a7b16962b..27a69ae2d8ba2d353a66e530f39a994d079dae8b 100644 (file)
@@ -757,7 +757,7 @@ extern tree c_finish_bc_name (location_t, tree, bool);
 extern bool c_objc_common_init (void);
 extern bool c_missing_noreturn_ok_p (tree);
 extern bool c_warn_unused_global_decl (const_tree);
-extern void c_initialize_diagnostics (diagnostic_context *);
+extern void c_initialize_diagnostics (diagnostics::context *);
 extern bool c_var_mod_p (tree x, tree fn);
 extern alias_set_type c_get_alias_set (tree);
 extern int c_type_dwarf_attribute (const_tree, int);
index 169a612f643b5041685141532425e8e0e849ecd4..b6a922a506c3b12b98f3b2a9b1c3aab00ab4cf40 100644 (file)
@@ -164,8 +164,10 @@ struct cl_option;
 struct cl_decoded_option;
 struct cl_option_handlers;
 class rich_location;
-class diagnostic_context;
-namespace diagnostics { class text_sink; }
+namespace diagnostics {
+  class context;
+  class text_sink;
+} // namespace diagnostics
 class pretty_printer;
 class diagnostic_event_id_t;
 typedef const char * (*diagnostic_input_charset_callback)(const char *);
index 6315a10a859d98a271ff3d3db6a2405df28746e5..150d921bee7909902a1b1ba2773356842f51aa6a 100644 (file)
@@ -8782,7 +8782,7 @@ extern alias_set_type cxx_get_alias_set           (tree);
 extern bool cxx_warn_unused_global_decl                (const_tree);
 extern size_t cp_tree_size                     (enum tree_code);
 extern bool cp_var_mod_type_p                  (tree, tree);
-extern void cxx_initialize_diagnostics         (diagnostic_context *);
+extern void cxx_initialize_diagnostics         (diagnostics::context *);
 extern int cxx_types_compatible_p              (tree, tree);
 extern bool cxx_block_may_fallthru             (const_tree);
 
index 555d8894f07eb025757087a9c3cca6d3900f3610..ea1d682a0824d0beae0fdf5134d6e96af706bdee 100644 (file)
@@ -242,7 +242,7 @@ get_current_template ()
 
 erroneous_templates_t *erroneous_templates;
 
-/* Callback function diagnostic_context::m_adjust_diagnostic_info.
+/* Callback function diagnostics::context::m_adjust_diagnostic_info.
 
    Errors issued when parsing a template are automatically treated like
    permerrors associated with the -Wtemplate-body flag and can be
@@ -250,7 +250,7 @@ erroneous_templates_t *erroneous_templates;
    issue an error if we later need to instantiate the template.  */
 
 static void
-cp_adjust_diagnostic_info (diagnostic_context *context,
+cp_adjust_diagnostic_info (diagnostics::context *context,
                           diagnostic_info *diagnostic)
 {
   if (diagnostic->m_kind == DK_ERROR)
@@ -298,14 +298,14 @@ cp_seen_error ()
    capacities.  */
 
 void
-cxx_initialize_diagnostics (diagnostic_context *context)
+cxx_initialize_diagnostics (diagnostics::context *context)
 {
   cxx_pretty_printer *pp = new cxx_pretty_printer ();
   pp->set_format_postprocessor (std::make_unique<cxx_format_postprocessor> ());
   context->set_pretty_printer (std::unique_ptr<pretty_printer> (pp));
 
   c_common_diagnostics_set_defaults (context);
-  diagnostic_text_starter (context) = cp_diagnostic_text_starter;
+  diagnostics::text_starter (context) = cp_diagnostic_text_starter;
   /* diagnostic_finalizer is already c_diagnostic_text_finalizer.  */
   context->set_format_decoder (cp_printer);
   context->set_adjust_diagnostic_info_callback (cp_adjust_diagnostic_info);
@@ -3804,7 +3804,7 @@ cp_print_error_function (diagnostics::text_sink &text_output,
   /* The above is true for constraint satisfaction also.  */
   if (current_failed_constraint)
     return;
-  diagnostic_context *const context = &text_output.get_context ();
+  diagnostics::context *const context = &text_output.get_context ();
   if (diagnostic_last_function_changed (context, diagnostic))
     {
       pretty_printer *const pp = text_output.get_printer ();
index a551509ec0b46b3c42a44d70048b05ecfb023b7f..d125c33877d1d536daadd105b34e3883b30026bc 100644 (file)
@@ -3883,9 +3883,9 @@ class GTY((chain_next ("%h.parent"), for_user)) module_state {
   void write_macro_maps (elf_out *to, range_t &, unsigned *crc_ptr);
   bool read_macro_maps (line_map_uint_t);
 
-  void write_diagnostic_classification (elf_out *, diagnostic_context *,
+  void write_diagnostic_classification (elf_out *, diagnostics::context *,
                                        unsigned *);
-  bool read_diagnostic_classification (diagnostic_context *);
+  bool read_diagnostic_classification (diagnostics::context *);
 
  private:
   void write_define (bytes_out &, const cpp_macro *);
@@ -18364,7 +18364,7 @@ dump_dc_change (unsigned index, unsigned opt, diagnostic_t dk)
 
 void
 module_state::write_diagnostic_classification (elf_out *to,
-                                              diagnostic_context *dc,
+                                              diagnostics::context *dc,
                                               unsigned *crc_p)
 {
   auto &changes = dc->get_classification_history ();
@@ -18433,7 +18433,7 @@ module_state::write_diagnostic_classification (elf_out *to,
 /* Read any #pragma GCC diagnostic info from the .dgc section.  */
 
 bool
-module_state::read_diagnostic_classification (diagnostic_context *dc)
+module_state::read_diagnostic_classification (diagnostics::context *dc)
 {
   bytes_in sec;
 
index ff647c244a50cf29d9849a74226d819fb4c1284b..84b606d9943f15926c227d6f3c80aa25744a7e60 100644 (file)
@@ -29,9 +29,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "diagnostics/sink.h"
 
-/* A diagnostic_context surrogate for stderr.  */
-static diagnostic_context global_diagnostic_context;
-diagnostic_context *global_dc = &global_diagnostic_context;
+/* A diagnostics::context surrogate for stderr.  */
+static diagnostics::context global_diagnostic_context;
+diagnostics::context *global_dc = &global_diagnostic_context;
 
 /* Standard error reporting routines in increasing order of severity.  */
 
@@ -49,7 +49,7 @@ verbatim (const char *gmsgid, ...)
   va_end (ap);
 }
 
-/* Wrapper around diagnostic_context::diagnostic_impl
+/* Wrapper around diagnostics::context::diagnostic_impl
    implying global_dc and taking a variable argument list.  */
 
 bool
index 8ebed0bf51a92d2161ffa6a6a9b2e0d6b3eedb28..847464d1e5f09cc4b7e6bf0e3747b3de4efc297c 100644 (file)
@@ -113,7 +113,7 @@ get_terminal_width (void)
 
 /* Set caret_max_width to value.  */
 void
-diagnostic_set_caret_max_width (diagnostic_context *context, int value)
+diagnostic_set_caret_max_width (diagnostics::context *context, int value)
 {
   /* One minus to account for the leading empty space.  */
   value = value ? value - 1
@@ -127,7 +127,7 @@ diagnostic_set_caret_max_width (diagnostic_context *context, int value)
 }
 
 void
-diagnostic_option_classifier::init (int n_opts)
+diagnostics::option_classifier::init (int n_opts)
 {
   m_n_opts = n_opts;
   m_classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
@@ -138,7 +138,7 @@ diagnostic_option_classifier::init (int n_opts)
 }
 
 void
-diagnostic_option_classifier::fini ()
+diagnostics::option_classifier::fini ()
 {
   XDELETEVEC (m_classify_diagnostic);
   m_classify_diagnostic = nullptr;
@@ -146,18 +146,18 @@ diagnostic_option_classifier::fini ()
   m_push_list.release ();
 }
 
-/* Save the diagnostic_option_classifier state to F for PCH
+/* Save the diagnostics::option_classifier state to F for PCH
    output.  Returns 0 on success, -1 on error.  */
 
 int
-diagnostic_option_classifier::pch_save (FILE *f)
+diagnostics::option_classifier::pch_save (FILE *f)
 {
   unsigned int lengths[2] = { m_classification_history.length (),
                              m_push_list.length () };
   if (fwrite (lengths, sizeof (lengths), 1, f) != 1
       || (lengths[0]
          && fwrite (m_classification_history.address (),
-                    sizeof (diagnostic_classification_change_t),
+                    sizeof (classification_change_t),
                     lengths[0], f) != lengths[0])
       || (lengths[1]
          && fwrite (m_push_list.address (), sizeof (int),
@@ -166,11 +166,11 @@ diagnostic_option_classifier::pch_save (FILE *f)
   return 0;
 }
 
-/* Read the diagnostic_option_classifier state from F for PCH
+/* Read the diagnostics::option_classifier state from F for PCH
    read.  Returns 0 on success, -1 on error.  */
 
 int
-diagnostic_option_classifier::pch_restore (FILE *f)
+diagnostics::option_classifier::pch_restore (FILE *f)
 {
   unsigned int lengths[2];
   if (fread (lengths, sizeof (lengths), 1, f) != 1)
@@ -181,7 +181,7 @@ diagnostic_option_classifier::pch_restore (FILE *f)
   m_push_list.safe_grow (lengths[1]);
   if ((lengths[0]
        && fread (m_classification_history.address (),
-                sizeof (diagnostic_classification_change_t),
+                sizeof (classification_change_t),
                 lengths[0], f) != lengths[0])
       || (lengths[1]
          && fread (m_push_list.address (), sizeof (int),
@@ -193,7 +193,7 @@ diagnostic_option_classifier::pch_restore (FILE *f)
 /* Save all diagnostic classifications in a stack.  */
 
 void
-diagnostic_option_classifier::push ()
+diagnostics::option_classifier::push ()
 {
   m_push_list.safe_push (m_classification_history.length ());
 }
@@ -202,7 +202,7 @@ diagnostic_option_classifier::push ()
    is empty, revert to the state based on command line parameters.  */
 
 void
-diagnostic_option_classifier::pop (location_t where)
+diagnostics::option_classifier::pop (location_t where)
 {
   int jump_to;
 
@@ -211,14 +211,14 @@ diagnostic_option_classifier::pop (location_t where)
   else
     jump_to = 0;
 
-  diagnostic_classification_change_t v = { where, jump_to, DK_POP };
+  classification_change_t v = { where, jump_to, DK_POP };
   m_classification_history.safe_push (v);
 }
 
 /* Initialize the diagnostic message outputting machinery.  */
 
 void
-diagnostic_context::initialize (int n_opts)
+diagnostics::context::initialize (int n_opts)
 {
   /* Allocate a basic pretty-printer.  Clients will replace this a
      much more elaborated pretty-printer if they wish.  */
@@ -310,7 +310,7 @@ diagnostic_context::initialize (int n_opts)
    without a VALUE, it initializes with DIAGNOSTICS_COLOR_DEFAULT.  */
 
 void
-diagnostic_context::color_init (int value)
+diagnostics::context::color_init (int value)
 {
   /* value == -1 is the default value.  */
   if (value < 0)
@@ -341,7 +341,7 @@ diagnostic_context::color_init (int value)
    handling "auto".  */
 
 void
-diagnostic_context::urls_init (int value)
+diagnostics::context::urls_init (int value)
 {
   /* value == -1 is the default value.  */
   if (value < 0)
@@ -372,7 +372,7 @@ diagnostic_context::urls_init (int value)
 /* Create the file_cache, if not already created, and tell it how to
    translate files on input.  */
 void
-diagnostic_context::
+diagnostics::context::
 initialize_input_context (diagnostic_input_charset_callback ccb,
                          bool should_skip_bom)
 {
@@ -382,7 +382,7 @@ initialize_input_context (diagnostic_input_charset_callback ccb,
 /* Do any cleaning up required after the last diagnostic is emitted.  */
 
 void
-diagnostic_context::finish ()
+diagnostics::context::finish ()
 {
   /* We might be handling a fatal error.
      Close any active diagnostic groups, which may trigger flushing
@@ -438,12 +438,12 @@ diagnostic_context::finish ()
   m_original_argv = nullptr;
 }
 
-/* Dump state of this diagnostic_context to OUT, for debugging.  */
+/* Dump state of this diagnostics::context to OUT, for debugging.  */
 
 void
-diagnostic_context::dump (FILE *out) const
+diagnostics::context::dump (FILE *out) const
 {
-  fprintf (out, "diagnostic_context:\n");
+  fprintf (out, "diagnostics::context:\n");
   m_diagnostic_counters.dump (out, 2);
   fprintf (out, "  reference printer:\n");
   m_reference_printer->dump (out, 4);
@@ -474,7 +474,7 @@ diagnostic_context::dump (FILE *out) const
    we ought to exit with a non-zero exit code.  */
 
 bool
-diagnostic_context::execution_failed_p () const
+diagnostics::context::execution_failed_p () const
 {
   /* Equivalent to (seen_error () || werrorcount), but on
      this context, rather than global_dc.  */
@@ -484,21 +484,21 @@ diagnostic_context::execution_failed_p () const
 }
 
 void
-diagnostic_context::remove_all_output_sinks ()
+diagnostics::context::remove_all_output_sinks ()
 {
   while (!m_sinks.is_empty ())
     delete m_sinks.pop ();
 }
 
 void
-diagnostic_context::set_sink (std::unique_ptr<diagnostics::sink> sink_)
+diagnostics::context::set_sink (std::unique_ptr<diagnostics::sink> sink_)
 {
   remove_all_output_sinks ();
   m_sinks.safe_push (sink_.release ());
 }
 
 diagnostics::sink &
-diagnostic_context::get_sink (size_t idx) const
+diagnostics::context::get_sink (size_t idx) const
 {
   gcc_assert (idx < m_sinks.length ());
   gcc_assert (m_sinks[idx]);
@@ -506,7 +506,7 @@ diagnostic_context::get_sink (size_t idx) const
 }
 
 void
-diagnostic_context::add_sink (std::unique_ptr<diagnostics::sink> sink_)
+diagnostics::context::add_sink (std::unique_ptr<diagnostics::sink> sink_)
 {
   m_sinks.safe_push (sink_.release ());
 }
@@ -514,7 +514,7 @@ diagnostic_context::add_sink (std::unique_ptr<diagnostics::sink> sink_)
 /* Return true if there are no machine-readable formats writing to stderr.  */
 
 bool
-diagnostic_context::supports_fnotice_on_stderr_p () const
+diagnostics::context::supports_fnotice_on_stderr_p () const
 {
   for (auto sink_ : m_sinks)
     if (sink_->machine_readable_stderr_p ())
@@ -523,14 +523,14 @@ diagnostic_context::supports_fnotice_on_stderr_p () const
 }
 
 void
-diagnostic_context::set_main_input_filename (const char *filename)
+diagnostics::context::set_main_input_filename (const char *filename)
 {
   for (auto sink_ : m_sinks)
     sink_->set_main_input_filename (filename);
 }
 
 void
-diagnostic_context::
+diagnostics::context::
 set_client_data_hooks (std::unique_ptr<diagnostics::client_data_hooks> hooks)
 {
   delete m_client_data_hooks;
@@ -539,10 +539,10 @@ set_client_data_hooks (std::unique_ptr<diagnostics::client_data_hooks> hooks)
 }
 
 void
-diagnostic_context::set_original_argv (unique_argv original_argv)
+diagnostics::context::set_original_argv (unique_argv original_argv)
 {
   /* Ideally we'd use a unique_argv for m_original_argv, but
-     diagnostic_context doesn't yet have a ctor/dtor pair.  */
+     diagnostics::context doesn't yet have a ctor/dtor pair.  */
 
   // Ensure any old value is freed
   freeargv (m_original_argv);
@@ -552,8 +552,8 @@ diagnostic_context::set_original_argv (unique_argv original_argv)
 }
 
 void
-diagnostic_context::
-set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
+diagnostics::context::
+set_option_manager (std::unique_ptr<diagnostics::option_manager> mgr,
                    unsigned lang_mask)
 {
   delete m_option_mgr;
@@ -562,7 +562,7 @@ set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
 }
 
 void
-diagnostic_context::push_owned_urlifier (std::unique_ptr<urlifier> ptr)
+diagnostics::context::push_owned_urlifier (std::unique_ptr<urlifier> ptr)
 {
   gcc_assert (m_urlifier_stack);
   const urlifier_stack_node node = { ptr.release (), true };
@@ -570,7 +570,7 @@ diagnostic_context::push_owned_urlifier (std::unique_ptr<urlifier> ptr)
 }
 
 void
-diagnostic_context::push_borrowed_urlifier (const urlifier &loan)
+diagnostics::context::push_borrowed_urlifier (const urlifier &loan)
 {
   gcc_assert (m_urlifier_stack);
   const urlifier_stack_node node = { const_cast <urlifier *> (&loan), false };
@@ -578,7 +578,7 @@ diagnostic_context::push_borrowed_urlifier (const urlifier &loan)
 }
 
 void
-diagnostic_context::pop_urlifier ()
+diagnostics::context::pop_urlifier ()
 {
   gcc_assert (m_urlifier_stack);
   gcc_assert (m_urlifier_stack->length () > 0);
@@ -589,7 +589,7 @@ diagnostic_context::pop_urlifier ()
 }
 
 const diagnostics::logical_locations::manager *
-diagnostic_context::get_logical_location_manager () const
+diagnostics::context::get_logical_location_manager () const
 {
   if (!m_client_data_hooks)
     return nullptr;
@@ -597,7 +597,7 @@ diagnostic_context::get_logical_location_manager () const
 }
 
 const urlifier *
-diagnostic_context::get_urlifier () const
+diagnostics::context::get_urlifier () const
 {
   if (!m_urlifier_stack)
     return nullptr;
@@ -611,7 +611,7 @@ diagnostic_context::get_urlifier () const
    Refresh all output sinks.  */
 
 void
-diagnostic_context::set_pretty_printer (std::unique_ptr<pretty_printer> pp)
+diagnostics::context::set_pretty_printer (std::unique_ptr<pretty_printer> pp)
 {
   delete m_reference_printer;
   m_reference_printer = pp.release ();
@@ -621,7 +621,7 @@ diagnostic_context::set_pretty_printer (std::unique_ptr<pretty_printer> pp)
 /* Give all output sinks a chance to rebuild their pretty_printer.  */
 
 void
-diagnostic_context::refresh_output_sinks ()
+diagnostics::context::refresh_output_sinks ()
 {
   for (auto sink_ : m_sinks)
     sink_->update_printer ();
@@ -631,7 +631,7 @@ diagnostic_context::refresh_output_sinks ()
    of all output sinks.  */
 
 void
-diagnostic_context::set_format_decoder (printer_fn format_decoder)
+diagnostics::context::set_format_decoder (printer_fn format_decoder)
 {
   pp_format_decoder (m_reference_printer) = format_decoder;
   for (auto sink_ : m_sinks)
@@ -639,7 +639,7 @@ diagnostic_context::set_format_decoder (printer_fn format_decoder)
 }
 
 void
-diagnostic_context::set_show_highlight_colors (bool val)
+diagnostics::context::set_show_highlight_colors (bool val)
 {
   pp_show_highlight_colors (m_reference_printer) = val;
   for (auto sink_ : m_sinks)
@@ -648,7 +648,7 @@ diagnostic_context::set_show_highlight_colors (bool val)
 }
 
 void
-diagnostic_context::set_prefixing_rule (diagnostic_prefixing_rule_t rule)
+diagnostics::context::set_prefixing_rule (diagnostic_prefixing_rule_t rule)
 {
   pp_prefixing_rule (m_reference_printer) = rule;
   for (auto sink_ : m_sinks)
@@ -657,7 +657,7 @@ diagnostic_context::set_prefixing_rule (diagnostic_prefixing_rule_t rule)
 }
 
 void
-diagnostic_context::create_edit_context ()
+diagnostics::context::create_edit_context ()
 {
   delete m_edit_context_ptr;
   gcc_assert (m_file_cache);
@@ -738,8 +738,7 @@ convert_column_unit (file_cache &fc,
     }
 }
 
-diagnostic_column_policy::
-diagnostic_column_policy (const diagnostic_context &dc)
+diagnostics::column_policy::column_policy (const diagnostics::context &dc)
 : m_file_cache (dc.get_file_cache ()),
   m_column_unit (dc.m_column_unit),
   m_column_origin (dc.m_column_origin),
@@ -751,7 +750,7 @@ diagnostic_column_policy (const diagnostic_context &dc)
    to the requested units and origin.  Return -1 if the column is
    invalid (<= 0).  */
 int
-diagnostic_column_policy::converted_column (expanded_location s) const
+diagnostics::column_policy::converted_column (expanded_location s) const
 {
   int one_based_col = convert_column_unit (m_file_cache,
                                           m_column_unit, m_tabstop, s);
@@ -763,9 +762,9 @@ diagnostic_column_policy::converted_column (expanded_location s) const
 /* Return a string describing a location e.g. "foo.c:42:10".  */
 
 label_text
-diagnostic_column_policy::get_location_text (const expanded_location &s,
-                                            bool show_column,
-                                            bool colorize) const
+diagnostics::column_policy::get_location_text (const expanded_location &s,
+                                              bool show_column,
+                                              bool colorize) const
 {
   const char *locus_cs = colorize_start (colorize, "locus");
   const char *locus_ce = colorize_stop (colorize);
@@ -784,15 +783,15 @@ diagnostic_column_policy::get_location_text (const expanded_location &s,
                                                 line_col, locus_ce));
 }
 
-diagnostic_location_print_policy::
-diagnostic_location_print_policy (const diagnostic_context &dc)
+diagnostics::location_print_policy::
+location_print_policy (const diagnostics::context &dc)
 : m_column_policy (dc),
   m_show_column (dc.m_show_column)
 {
 }
 
-diagnostic_location_print_policy::
-diagnostic_location_print_policy (const diagnostics::text_sink &text_output)
+diagnostics::location_print_policy::
+location_print_policy (const diagnostics::text_sink &text_output)
 :
   m_column_policy (text_output.get_context ()),
   m_show_column (text_output.get_context ().m_show_column)
@@ -909,10 +908,10 @@ bt_err_callback (void *data ATTRIBUTE_UNUSED, const char *msg, int errnum)
 
 /* Check if we've met the maximum error limit, and if so fatally exit
    with a message.
-   FLUSH indicates whether a diagnostic_context::finish call is needed.  */
+   FLUSH indicates whether a diagnostics::context::finish call is needed.  */
 
 void
-diagnostic_context::check_max_errors (bool flush)
+diagnostics::context::check_max_errors (bool flush)
 {
   if (!m_max_errors)
     return;
@@ -936,7 +935,7 @@ diagnostic_context::check_max_errors (bool flush)
    is written out.  This function does not always return.  */
 
 void
-diagnostic_context::action_after_output (diagnostic_t diag_kind)
+diagnostics::context::action_after_output (diagnostic_t diag_kind)
 {
   switch (diag_kind)
     {
@@ -1013,7 +1012,7 @@ diagnostic_context::action_after_output (diagnostic_t diag_kind)
    its future children if any.  */
 
 void
-diagnostic_context::inhibit_notes_in_group (bool inhibit)
+diagnostics::context::inhibit_notes_in_group (bool inhibit)
 {
   int curr_depth = (m_diagnostic_groups.m_group_nesting_depth
                    + m_diagnostic_groups.m_diagnostic_nesting_level);
@@ -1043,7 +1042,7 @@ diagnostic_context::inhibit_notes_in_group (bool inhibit)
 /* Return whether notes must be inhibited in the current diagnostic_group.  */
 
 bool
-diagnostic_context::notes_inhibited_in_group () const
+diagnostics::context::notes_inhibited_in_group () const
 {
   if (m_diagnostic_groups.m_inhibiting_notes_from
       && (m_diagnostic_groups.m_group_nesting_depth
@@ -1084,8 +1083,8 @@ diagnostics::logical_locations::manager::function_p (key k) const
    range.  If OPTION_ID is zero, the new setting is for all the
    diagnostics.  */
 diagnostic_t
-diagnostic_option_classifier::
-classify_diagnostic (const diagnostic_context *context,
+diagnostics::option_classifier::
+classify_diagnostic (const diagnostics::context *context,
                     diagnostic_option_id option_id,
                     diagnostic_t new_kind,
                     location_t where)
@@ -1113,7 +1112,7 @@ classify_diagnostic (const diagnostic_context *context,
          m_classify_diagnostic[option_id.m_idx] = old_kind;
        }
 
-      diagnostic_classification_change_t *p;
+      classification_change_t *p;
       FOR_EACH_VEC_ELT_REVERSE (m_classification_history, i, p)
        if (p->option == option_id.m_idx)
          {
@@ -1121,7 +1120,7 @@ classify_diagnostic (const diagnostic_context *context,
            break;
          }
 
-      diagnostic_classification_change_t v
+      classification_change_t v
        = { where, option_id.m_idx, new_kind };
       m_classification_history.safe_push (v);
     }
@@ -1221,7 +1220,7 @@ print_parseable_fixits (file_cache &fc,
 /* Update the inlining info in this context for a DIAGNOSTIC.  */
 
 void
-diagnostic_context::get_any_inlining_info (diagnostic_info *diagnostic)
+diagnostics::context::get_any_inlining_info (diagnostic_info *diagnostic)
 {
   auto &ilocs = diagnostic->m_iinfo.m_ilocs;
 
@@ -1249,7 +1248,7 @@ diagnostic_context::get_any_inlining_info (diagnostic_info *diagnostic)
    otherwise.  */
 
 diagnostic_t
-diagnostic_option_classifier::
+diagnostics::option_classifier::
 update_effective_level_from_pragmas (diagnostic_info *diagnostic) const
 {
   if (m_classification_history.is_empty ())
@@ -1263,7 +1262,7 @@ update_effective_level_from_pragmas (diagnostic_info *diagnostic) const
     {
       /* FIXME: Stupid search.  Optimize later. */
       unsigned int i;
-      diagnostic_classification_change_t *p;
+      classification_change_t *p;
       FOR_EACH_VEC_ELT_REVERSE (m_classification_history, i, p)
        {
          location_t pragloc = p->location;
@@ -1305,7 +1304,7 @@ get_cwe_url (int cwe)
    as appropriate for #pragma GCC diagnostic and -Werror=foo.  */
 
 bool
-diagnostic_context::diagnostic_enabled (diagnostic_info *diagnostic)
+diagnostics::context::diagnostic_enabled (diagnostic_info *diagnostic)
 {
   /* Update the inlining stack for this diagnostic.  */
   get_any_inlining_info (diagnostic);
@@ -1349,7 +1348,7 @@ diagnostic_context::diagnostic_enabled (diagnostic_info *diagnostic)
 /* Returns whether warning OPTION_ID is enabled at LOC.  */
 
 bool
-diagnostic_context::warning_enabled_at (location_t loc,
+diagnostics::context::warning_enabled_at (location_t loc,
                                        diagnostic_option_id option_id)
 {
   if (!diagnostic_report_warnings_p (this, loc))
@@ -1367,7 +1366,7 @@ diagnostic_context::warning_enabled_at (location_t loc,
 /* Emit a diagnostic within a diagnostic group on this context.  */
 
 bool
-diagnostic_context::
+diagnostics::context::
 emit_diagnostic_with_group (diagnostic_t kind,
                            rich_location &richloc,
                            const diagnostics::metadata *metadata,
@@ -1390,7 +1389,7 @@ emit_diagnostic_with_group (diagnostic_t kind,
 /* As above, but taking a va_list *.  */
 
 bool
-diagnostic_context::
+diagnostics::context::
 emit_diagnostic_with_group_va (diagnostic_t kind,
                               rich_location &richloc,
                               const diagnostics::metadata *metadata,
@@ -1408,13 +1407,13 @@ emit_diagnostic_with_group_va (diagnostic_t kind,
 }
 
 /* Report a diagnostic message (an error or a warning) as specified by
-   this diagnostic_context.
+   this diagnostics::context.
    front-end independent format specifiers are exactly those described
    in the documentation of output_format.
    Return true if a diagnostic was printed, false otherwise.  */
 
 bool
-diagnostic_context::report_diagnostic (diagnostic_info *diagnostic)
+diagnostics::context::report_diagnostic (diagnostic_info *diagnostic)
 {
   diagnostic_t orig_diag_kind = diagnostic->m_kind;
 
@@ -1527,7 +1526,7 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic)
       ((diagnostic->m_kind == DK_ERROR && orig_diag_kind == DK_WARNING)
        ? DK_WERROR
        : diagnostic->m_kind);
-    diagnostic_counters &counters
+    diagnostics::counters &counters
       = (m_diagnostic_buffer
         ? m_diagnostic_buffer->m_diagnostic_counters
         : m_diagnostic_counters);
@@ -1609,7 +1608,7 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic)
 }
 
 void
-diagnostic_context::report_verbatim (text_info &text)
+diagnostics::context::report_verbatim (text_info &text)
 {
   va_list *orig_args = text.m_args_ptr;
   for (auto sink_ : m_sinks)
@@ -1623,7 +1622,7 @@ diagnostic_context::report_verbatim (text_info &text)
 }
 
 void
-diagnostic_context::
+diagnostics::context::
 report_global_digraph (const diagnostics::digraphs::lazy_digraph &ldg)
 {
   for (auto sink_ : m_sinks)
@@ -1685,7 +1684,7 @@ trim_filename (const char *name)
    permerror, error, error_at, error_at, sorry, fatal_error, internal_error,
    and internal_error_no_backtrace, as documented and defined below.  */
 bool
-diagnostic_context::diagnostic_impl (rich_location *richloc,
+diagnostics::context::diagnostic_impl (rich_location *richloc,
                                     const diagnostics::metadata *metadata,
                                     diagnostic_option_id option_id,
                                     const char *gmsgid,
@@ -1711,7 +1710,7 @@ diagnostic_context::diagnostic_impl (rich_location *richloc,
 /* Implement inform_n, warning_n, and error_n, as documented and
    defined below.  */
 bool
-diagnostic_context::diagnostic_n_impl (rich_location *richloc,
+diagnostics::context::diagnostic_n_impl (rich_location *richloc,
                                       const diagnostics::metadata *metadata,
                                       diagnostic_option_id option_id,
                                       unsigned HOST_WIDE_INT n,
@@ -1742,7 +1741,7 @@ diagnostic_context::diagnostic_n_impl (rich_location *richloc,
 /* Emit DIAGRAM to this context, respecting the output format.  */
 
 void
-diagnostic_context::emit_diagram (const diagnostics::diagram &diag)
+diagnostics::context::emit_diagram (const diagnostics::diagram &diag)
 {
   if (m_diagrams.m_theme == nullptr)
     return;
@@ -1757,7 +1756,7 @@ diagnostic_context::emit_diagram (const diagnostics::diagram &diag)
    This mustn't use internal_error, that will cause infinite recursion.  */
 
 void
-diagnostic_context::error_recursion ()
+diagnostics::context::error_recursion ()
 {
   if (m_lock < 3)
     pp_newline_and_flush (m_reference_printer);
@@ -1816,16 +1815,16 @@ fancy_abort (const char *file, int line, const char *function)
   internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
 }
 
-/* class diagnostic_context.  */
+/* class diagnostics::context.  */
 
 void
-diagnostic_context::begin_group ()
+diagnostics::context::begin_group ()
 {
   m_diagnostic_groups.m_group_nesting_depth++;
 }
 
 void
-diagnostic_context::end_group ()
+diagnostics::context::end_group ()
 {
   if (--m_diagnostic_groups.m_group_nesting_depth == 0)
     {
@@ -1842,13 +1841,13 @@ diagnostic_context::end_group ()
 }
 
 void
-diagnostic_context::push_nesting_level ()
+diagnostics::context::push_nesting_level ()
 {
   ++m_diagnostic_groups.m_diagnostic_nesting_level;
 }
 
 void
-diagnostic_context::pop_nesting_level ()
+diagnostics::context::pop_nesting_level ()
 {
   --m_diagnostic_groups.m_diagnostic_nesting_level;
   /* We're popping one level, so might need to stop inhibiting notes.  */
@@ -1872,7 +1871,7 @@ diagnostics::sink::on_report_verbatim (text_info &)
    file-based output formats.  */
 
 void
-diagnostics::output_format_init (diagnostic_context &context,
+diagnostics::output_format_init (diagnostics::context &context,
                                 const char *main_input_filename_,
                                 const char *base_file_name,
                                 enum diagnostics_output_format format,
@@ -1909,7 +1908,7 @@ diagnostics::output_format_init (diagnostic_context &context,
    (or nullptr for "no diagrams").  */
 
 void
-diagnostic_context::
+diagnostics::context::
 set_text_art_charset (enum diagnostic_text_art_charset charset)
 {
   delete m_diagrams.m_theme;
@@ -1943,7 +1942,7 @@ set_text_art_charset (enum diagnostic_text_art_charset charset)
    to this function.  */
 
 void
-diagnostic_context::set_diagnostic_buffer (diagnostics::buffer *buffer_)
+diagnostics::context::set_diagnostic_buffer (diagnostics::buffer *buffer_)
 {
   /* We don't allow changing buffering within a diagnostic group
      (to simplify handling of buffered diagnostics within the
@@ -1977,7 +1976,7 @@ diagnostic_context::set_diagnostic_buffer (diagnostics::buffer *buffer_)
 /* Clear BUFFER without flushing it.  */
 
 void
-diagnostic_context::clear_diagnostic_buffer (diagnostics::buffer &buffer_)
+diagnostics::context::clear_diagnostic_buffer (diagnostics::buffer &buffer_)
 {
   if (buffer_.m_per_sink_buffers)
     for (auto per_sink_buffer_ : *buffer_.m_per_sink_buffers)
@@ -1993,7 +1992,7 @@ diagnostic_context::clear_diagnostic_buffer (diagnostics::buffer &buffer_)
 /* Flush the diagnostics in BUFFER to this context, clearing BUFFER.  */
 
 void
-diagnostic_context::flush_diagnostic_buffer (diagnostics::buffer &buffer_)
+diagnostics::context::flush_diagnostic_buffer (diagnostics::buffer &buffer_)
 {
   bool had_errors
     = (buffer_.m_diagnostic_counters.m_count_for_kind[DK_ERROR] > 0
@@ -2007,15 +2006,15 @@ diagnostic_context::flush_diagnostic_buffer (diagnostics::buffer &buffer_)
   check_max_errors (true);
 }
 
-/* struct diagnostic_counters.  */
+/* struct diagnostics::counters.  */
 
-diagnostic_counters::diagnostic_counters ()
+diagnostics::counters::counters ()
 {
   clear ();
 }
 
 void
-diagnostic_counters::dump (FILE *out, int indent) const
+diagnostics::counters::dump (FILE *out, int indent) const
 {
   fprintf (out, "%*scounts:\n", indent, "");
   bool none = true;
@@ -2033,7 +2032,7 @@ diagnostic_counters::dump (FILE *out, int indent) const
 }
 
 void
-diagnostic_counters::move_to (diagnostic_counters &dest)
+diagnostics::counters::move_to (diagnostics::counters &dest)
 {
   for (int i = 0; i < DK_LAST_DIAGNOSTIC_KIND; i++)
     dest.m_count_for_kind[i] += m_count_for_kind[i];
@@ -2041,14 +2040,14 @@ diagnostic_counters::move_to (diagnostic_counters &dest)
 }
 
 void
-diagnostic_counters::clear ()
+diagnostics::counters::clear ()
 {
   memset (&m_count_for_kind, 0, sizeof m_count_for_kind);
 }
 
 /* class diagnostics::buffer.  */
 
-diagnostics::buffer::buffer (diagnostic_context &ctxt)
+diagnostics::buffer::buffer (diagnostics::context &ctxt)
 : m_ctxt (ctxt),
   m_per_sink_buffers (nullptr)
 {
@@ -2344,7 +2343,7 @@ test_print_parseable_fixits_bytes_vs_display_columns ()
 }
 
 /* Verify that
-     diagnostic_column_policy::get_location_text (..., SHOW_COLUMN, ...)
+     diagnostics::column_policy::get_location_text (..., SHOW_COLUMN, ...)
    generates EXPECTED_LOC_TEXT, given FILENAME, LINE, COLUMN, with
    colorization disabled.  */
 
@@ -2367,7 +2366,7 @@ assert_location_text (const char *expected_loc_text,
   xloc.data = nullptr;
   xloc.sysp = false;
 
-  diagnostic_column_policy column_policy (dc);
+  diagnostics::column_policy column_policy (dc);
   label_text actual_loc_text
     = column_policy.get_location_text (xloc, show_column, false);
   ASSERT_STREQ (expected_loc_text, actual_loc_text.get ());
index 4388655e83d72eeac48f865ded6201da43a4e74c..83904ee00a8d0fe6453965fc8bad813576dfa3cd 100644 (file)
@@ -155,976 +155,19 @@ enum diagnostic_text_art_charset
 #include "diagnostics/diagnostic-info.h"
 typedef diagnostics::diagnostic_info diagnostic_info;
 
-/*  Forward declarations.  */
-class diagnostic_location_print_policy;
-class diagnostic_source_print_policy;
-
-typedef void (*diagnostic_text_starter_fn) (diagnostics::text_sink &,
-                                           const diagnostic_info *);
-
-struct to_text;
-struct to_html;
-
-extern pretty_printer *get_printer (to_text &);
-
-template <typename Sink>
-using diagnostic_start_span_fn = void (*) (const diagnostic_location_print_policy &,
-                                          Sink &sink,
-                                          expanded_location);
-
-typedef void (*diagnostic_text_finalizer_fn) (diagnostics::text_sink &,
-                                             const diagnostic_info *,
-                                             diagnostic_t);
-
-/* Abstract base class for the diagnostic subsystem to make queries
-   about command-line options.  */
-
-class diagnostic_option_manager
-{
-public:
-  virtual ~diagnostic_option_manager () {}
-
-  /* Return 1 if option OPTION_ID is enabled, 0 if it is disabled,
-     or -1 if it isn't a simple on-off switch
-     (or if the value is unknown, typically set later in target).  */
-  virtual int option_enabled_p (diagnostic_option_id option_id) const = 0;
-
-  /* Return malloced memory for the name of the option OPTION_ID
-     which enabled a diagnostic, originally of type ORIG_DIAG_KIND but
-     possibly converted to DIAG_KIND by options such as -Werror.
-     May return NULL if no name is to be printed.
-     May be passed 0 as well as the index of a particular option.  */
-  virtual char *make_option_name (diagnostic_option_id option_id,
-                                 diagnostic_t orig_diag_kind,
-                                 diagnostic_t diag_kind) const = 0;
-
-  /* Return malloced memory for a URL describing the option that controls
-     a diagnostic.
-     May return NULL if no URL is available.
-     May be passed 0 as well as the index of a particular option.  */
-  virtual char *make_option_url (diagnostic_option_id option_id) const = 0;
-};
-
-/* A stack of sets of classifications: each entry in the stack is
-   a mapping from option index to diagnostic severity that can be changed
-   via pragmas.  The stack can be pushed and popped.  */
-
-class diagnostic_option_classifier
-{
-public:
-  void init (int n_opts);
-  void fini ();
-
-  /* Save all diagnostic classifications in a stack.  */
-  void push ();
-
-  /* Restore the topmost classification set off the stack.  If the stack
-     is empty, revert to the state based on command line parameters.  */
-  void pop (location_t where);
-
-  bool option_unspecified_p (diagnostic_option_id option_id) const
-  {
-    return get_current_override (option_id) == DK_UNSPECIFIED;
-  }
-
-  diagnostic_t get_current_override (diagnostic_option_id option_id) const
-  {
-    gcc_assert (option_id.m_idx < m_n_opts);
-    return m_classify_diagnostic[option_id.m_idx];
-  }
-
-  diagnostic_t
-  classify_diagnostic (const diagnostic_context *context,
-                      diagnostic_option_id option_id,
-                      diagnostic_t new_kind,
-                      location_t where);
-
-  diagnostic_t
-  update_effective_level_from_pragmas (diagnostic_info *diagnostic) const;
-
-  int pch_save (FILE *);
-  int pch_restore (FILE *);
-
-private:
-  /* Each time a diagnostic's classification is changed with a pragma,
-     we record the change and the location of the change in an array of
-     these structs.  */
-  struct diagnostic_classification_change_t
-  {
-    location_t location;
-
-    /* For DK_POP, this is the index of the corresponding push (as stored
-       in m_push_list).
-       Otherwise, this is an option index.  */
-    int option;
-
-    diagnostic_t kind;
-  };
-
-  int m_n_opts;
-
-  /* For each option index that can be passed to warning() et al
-     (OPT_* from options.h when using this code with the core GCC
-     options), this array may contain a new kind that the diagnostic
-     should be changed to before reporting, or DK_UNSPECIFIED to leave
-     it as the reported kind, or DK_IGNORED to not report it at
-     all.  */
-  diagnostic_t *m_classify_diagnostic;
-
-  /* History of all changes to the classifications above.  This list
-     is stored in location-order, so we can search it, either
-     binary-wise or end-to-front, to find the most recent
-     classification for a given diagnostic, given the location of the
-     diagnostic.  */
-  vec<diagnostic_classification_change_t> m_classification_history;
-
-  /* For diagnostic_context::get_classification_history, declared later.  */
-  friend class diagnostic_context;
-
-  /* For pragma push/pop.  */
-  vec<int> m_push_list;
-};
-
-/* A bundle of options relating to printing the user's source code
-   (potentially with a margin, underlining, labels, etc).  */
-
-struct diagnostic_source_printing_options
-{
-  /* True if we should print the source line with a caret indicating
-     the location.
-     Corresponds to -fdiagnostics-show-caret.  */
-  bool enabled;
-
-  /* Maximum width of the source line printed.  */
-  int max_width;
-
-  /* Character used at the caret when printing source locations.  */
-  char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
-
-  /* When printing source code, should the characters at carets and ranges
-     be colorized? (assuming colorization is on at all).
-     This should be true for frontends that generate range information
-     (so that the ranges of code are colorized),
-     and false for frontends that merely specify points within the
-     source code (to avoid e.g. colorizing just the first character in
-     a token, which would look strange).  */
-  bool colorize_source_p;
-
-  /* When printing source code, should labelled ranges be printed?
-     Corresponds to -fdiagnostics-show-labels.  */
-  bool show_labels_p;
-
-  /* When printing source code, should there be a left-hand margin
-     showing line numbers?
-     Corresponds to -fdiagnostics-show-line-numbers.  */
-  bool show_line_numbers_p;
-
-  /* If printing source code, what should the minimum width of the margin
-     be?  Line numbers will be right-aligned, and padded to this width.
-     Corresponds to -fdiagnostics-minimum-margin-width=VALUE.  */
-  int min_margin_width;
-
-  /* Usable by plugins; if true, print a debugging ruler above the
-     source output.  */
-  bool show_ruler_p;
-
-  /* When printing events in an inline path, should we print lines
-     visualizing links between related events (e.g. for CFG paths)?
-     Corresponds to -fdiagnostics-show-event-links.  */
-  bool show_event_links_p;
-};
-
-/* A bundle of state for determining column numbers in diagnostics
-   (tab stops, whether to start at 0 or 1, etc).
-   Uses a file_cache to handle tabs.  */
-
-class diagnostic_column_policy
-{
-public:
-  diagnostic_column_policy (const diagnostic_context &dc);
-
-  int converted_column (expanded_location s) const;
-
-  label_text get_location_text (const expanded_location &s,
-                               bool show_column,
-                               bool colorize) const;
-
-  int get_tabstop () const { return m_tabstop; }
-
-private:
-  file_cache &m_file_cache;
-  enum diagnostics_column_unit m_column_unit;
-  int m_column_origin;
-  int m_tabstop;
-};
-
-/* A bundle of state for printing locations within diagnostics
-   (e.g. "FILENAME:LINE:COLUMN"), to isolate the interactions between
-   diagnostic_context and the start_span callbacks.  */
-
-class diagnostic_location_print_policy
-{
-public:
-  diagnostic_location_print_policy (const diagnostic_context &dc);
-  diagnostic_location_print_policy (const diagnostics::text_sink &);
-
-  bool show_column_p () const { return m_show_column; }
-
-  const diagnostic_column_policy &
-  get_column_policy () const { return m_column_policy; }
-
-  void
-  print_text_span_start (const diagnostic_context &dc,
-                        pretty_printer &pp,
-                        const expanded_location &exploc);
-
-  void
-  print_html_span_start (const diagnostic_context &dc,
-                        xml::printer &xp,
-                        const expanded_location &exploc);
-
-private:
-  diagnostic_column_policy m_column_policy;
-  bool m_show_column;
-};
-
-/* Abstract base class for optionally supplying extra tags when writing
-   out annotation labels in HTML output.  */
-
-class html_label_writer
-{
-public:
-  virtual ~html_label_writer () {}
-  virtual void begin_label () = 0;
-  virtual void end_label () = 0;
-};
-
-/* A bundle of state for printing source within a diagnostic,
-   to isolate the interactions between diagnostic_context and the
-   implementation of diagnostic_show_locus.  */
-
-class diagnostic_source_print_policy
-{
-public:
-  diagnostic_source_print_policy (const diagnostic_context &);
-  diagnostic_source_print_policy (const diagnostic_context &,
-                                 const diagnostic_source_printing_options &);
-
-  void
-  print (pretty_printer &pp,
-        const rich_location &richloc,
-        diagnostic_t diagnostic_kind,
-        diagnostics::source_effect_info *effect_info) const;
-
-  void
-  print_as_html (xml::printer &xp,
-                const rich_location &richloc,
-                diagnostic_t diagnostic_kind,
-                diagnostics::source_effect_info *effect_info,
-                html_label_writer *label_writer) const;
-
-  const diagnostic_source_printing_options &
-  get_options () const { return m_options; }
-
-  diagnostic_start_span_fn<to_text>
-  get_text_start_span_fn () const { return m_text_start_span_cb; }
-
-  diagnostic_start_span_fn<to_html>
-  get_html_start_span_fn () const { return m_html_start_span_cb; }
-
-  file_cache &
-  get_file_cache () const { return m_file_cache; }
-
-  enum diagnostics_escape_format
-  get_escape_format () const
-  {
-    return m_escape_format;
-  }
-
-  text_art::theme *
-  get_diagram_theme () const { return m_diagram_theme; }
-
-  const diagnostic_column_policy &get_column_policy () const
-  {
-    return m_location_policy.get_column_policy ();
-  }
-
-  const diagnostic_location_print_policy &get_location_policy () const
-  {
-    return m_location_policy;
-  }
-
-private:
-  const diagnostic_source_printing_options &m_options;
-  class diagnostic_location_print_policy m_location_policy;
-  diagnostic_start_span_fn<to_text> m_text_start_span_cb;
-  diagnostic_start_span_fn<to_html> m_html_start_span_cb;
-  file_cache &m_file_cache;
-
-  /* Other data copied from diagnostic_context.  */
-  text_art::theme *m_diagram_theme;
-  enum diagnostics_escape_format m_escape_format;
-};
-
-/* A collection of counters of diagnostics, per-kind
-   (e.g. "3 errors and 1 warning"), for use by both diagnostic_context
-   and by diagnostics::buffer.  */
-
-struct diagnostic_counters
-{
-  diagnostic_counters ();
-
-  void dump (FILE *out, int indent) const;
-  void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
-
-  int get_count (diagnostic_t kind) const { return m_count_for_kind[kind]; }
-
-  void move_to (diagnostic_counters &dest);
-  void clear ();
-
-  int m_count_for_kind[DK_LAST_DIAGNOSTIC_KIND];
-};
-
-/* This class encapsulates the state of the diagnostics subsystem
-   as a whole (either directly, or via owned objects of other classes, to
-   avoid global variables).
-
-   It has responsibility for:
-   - being a central place for clients to report diagnostics
-   - reporting those diagnostics to zero or more output sinks
-     (e.g. text vs SARIF)
-   - providing a "dump" member function for a debug dump of the state of
-     the diagnostics subsytem
-   - direct vs buffered diagnostics (see class diagnostics::buffer)
-   - tracking the original argv of the program (for SARIF output)
-   - crash-handling
-
-   It delegates responsibility to various other classes:
-   - the various output sinks (instances of diagnostics::sink
-     subclasses)
-   - formatting of messages (class pretty_printer)
-   - an optional urlifier to inject URLs into formatted messages
-   - counting the number of diagnostics reported of each kind
-     (class diagnostic_counters)
-   - calling out to a diagnostic_option_manager to determine if
-     a particular warning is enabled or disabled
-   - tracking pragmas that enable/disable warnings in a range of
-     source code
-   - a cache for use when quoting the user's source code (class file_cache)
-   - a text_art::theme
-   - a diagnostics::edit_context for generating patches from fix-it hints
-   - diagnostics::client_data_hooks for metadata.
-
-   Try to avoid adding new responsibilities to this class itself, to avoid
-   the "blob" anti-pattern.  */
-
-class diagnostic_context
-{
-public:
-  /* Give access to m_text_callbacks.  */
-  friend diagnostic_text_starter_fn &
-  diagnostic_text_starter (diagnostic_context *context);
-  friend diagnostic_start_span_fn<to_text> &
-  diagnostic_start_span (diagnostic_context *context);
-  friend diagnostic_text_finalizer_fn &
-  diagnostic_text_finalizer (diagnostic_context *context);
-
-  friend class diagnostic_source_print_policy;
-  friend class diagnostics::text_sink;
-  friend class diagnostics::buffer;
-
-  typedef void (*set_locations_callback_t) (diagnostic_context *,
-                                           diagnostic_info *);
-
-  void initialize (int n_opts);
-  void color_init (int value);
-  void urls_init (int value);
-  void set_pretty_printer (std::unique_ptr<pretty_printer> pp);
-  void refresh_output_sinks ();
-
-  void finish ();
-
-  void dump (FILE *out) const;
-  void DEBUG_FUNCTION dump () const { dump (stderr); }
-
-  bool execution_failed_p () const;
-
-  void set_original_argv (unique_argv original_argv);
-  const char * const *get_original_argv ()
-  {
-    return const_cast<const char * const *> (m_original_argv);
-  }
-
-  void set_set_locations_callback (set_locations_callback_t cb)
-  {
-    m_set_locations_cb = cb;
-  }
-
-  void
-  initialize_input_context (diagnostic_input_charset_callback ccb,
-                           bool should_skip_bom);
-
-  void begin_group ();
-  void end_group ();
-
-  void push_nesting_level ();
-  void pop_nesting_level ();
-
-  bool warning_enabled_at (location_t loc, diagnostic_option_id option_id);
-
-  bool option_unspecified_p (diagnostic_option_id option_id) const
-  {
-    return m_option_classifier.option_unspecified_p (option_id);
-  }
-
-  bool emit_diagnostic_with_group (diagnostic_t kind,
-                                  rich_location &richloc,
-                                  const diagnostics::metadata *metadata,
-                                  diagnostic_option_id option_id,
-                                  const char *gmsgid, ...)
-    ATTRIBUTE_GCC_DIAG(6,7);
-  bool emit_diagnostic_with_group_va (diagnostic_t kind,
-                                     rich_location &richloc,
-                                     const diagnostics::metadata *metadata,
-                                     diagnostic_option_id option_id,
-                                     const char *gmsgid, va_list *ap)
-    ATTRIBUTE_GCC_DIAG(6,0);
-
-  bool report_diagnostic (diagnostic_info *);
-  void report_verbatim (text_info &);
-
-  /* Report a directed graph associated with the run as a whole
-     to any sinks that support directed graphs.  */
-  void
-  report_global_digraph (const diagnostics::digraphs::lazy_digraph &);
-
-  diagnostic_t
-  classify_diagnostic (diagnostic_option_id option_id,
-                      diagnostic_t new_kind,
-                      location_t where)
-  {
-    return m_option_classifier.classify_diagnostic (this,
-                                                   option_id,
-                                                   new_kind,
-                                                   where);
-  }
-
-  void push_diagnostics (location_t where ATTRIBUTE_UNUSED)
-  {
-    m_option_classifier.push ();
-  }
-  void pop_diagnostics (location_t where)
-  {
-    m_option_classifier.pop (where);
-  }
-
-  void maybe_show_locus (const rich_location &richloc,
-                        const diagnostic_source_printing_options &opts,
-                        diagnostic_t diagnostic_kind,
-                        pretty_printer &pp,
-                        diagnostics::source_effect_info *effect_info);
-  void maybe_show_locus_as_html (const rich_location &richloc,
-                                const diagnostic_source_printing_options &opts,
-                                diagnostic_t diagnostic_kind,
-                                xml::printer &xp,
-                                diagnostics::source_effect_info *effect_info,
-                                html_label_writer *label_writer);
-
-  void emit_diagram (const diagnostics::diagram &diag);
-
-  /* Various setters for use by option-handling logic.  */
-  void set_sink (std::unique_ptr<diagnostics::sink> sink_);
-  void set_text_art_charset (enum diagnostic_text_art_charset charset);
-  void set_client_data_hooks (std::unique_ptr<diagnostics::client_data_hooks> hooks);
-
-  void push_owned_urlifier (std::unique_ptr<urlifier>);
-  void push_borrowed_urlifier (const urlifier &);
-  void pop_urlifier ();
-
-  void create_edit_context ();
-  void set_warning_as_error_requested (bool val)
-  {
-    m_warning_as_error_requested = val;
-  }
-  void set_report_bug (bool val) { m_report_bug = val; }
-  void set_extra_output_kind (enum diagnostics_extra_output_kind kind)
-  {
-    m_extra_output_kind = kind;
-  }
-  void set_show_cwe (bool val) { m_show_cwe = val;  }
-  void set_show_rules (bool val) { m_show_rules = val; }
-  void set_show_highlight_colors (bool val);
-  void set_path_format (enum diagnostic_path_format val)
-  {
-    m_path_format = val;
-  }
-  void set_show_path_depths (bool val) { m_show_path_depths = val; }
-  void set_show_option_requested (bool val) { m_show_option_requested = val; }
-  void set_max_errors (int val) { m_max_errors = val; }
-  void set_escape_format (enum diagnostics_escape_format val)
-  {
-    m_escape_format = val;
-  }
-
-  void set_format_decoder (printer_fn format_decoder);
-  void set_prefixing_rule (diagnostic_prefixing_rule_t rule);
-
-  /* Various accessors.  */
-  bool warning_as_error_requested_p () const
-  {
-    return m_warning_as_error_requested;
-  }
-  bool show_path_depths_p () const { return m_show_path_depths; }
-  diagnostics::sink &get_sink (size_t idx) const;
-  enum diagnostic_path_format get_path_format () const { return m_path_format; }
-  enum diagnostics_escape_format get_escape_format () const
-  {
-    return m_escape_format;
-  }
-
-  file_cache &
-  get_file_cache () const
-  {
-    gcc_assert (m_file_cache);
-    return *m_file_cache;
-  }
-
-  diagnostics::edit_context *get_edit_context () const
-  {
-    return m_edit_context_ptr;
-  }
-  const diagnostics::client_data_hooks *get_client_data_hooks () const
-  {
-    return m_client_data_hooks;
-  }
-
-  const diagnostics::logical_locations::manager *
-  get_logical_location_manager () const;
-
-  const urlifier *get_urlifier () const;
-
-  text_art::theme *get_diagram_theme () const { return m_diagrams.m_theme; }
-
-  int &diagnostic_count (diagnostic_t kind)
-  {
-    return m_diagnostic_counters.m_count_for_kind[kind];
-  }
-  int diagnostic_count (diagnostic_t kind) const
-  {
-    return m_diagnostic_counters.get_count (kind);
-  }
-
-  /* Option-related member functions.  */
-  inline bool option_enabled_p (diagnostic_option_id option_id) const
-  {
-    if (!m_option_mgr)
-      return true;
-    return m_option_mgr->option_enabled_p (option_id);
-  }
-
-  inline char *make_option_name (diagnostic_option_id option_id,
-                                diagnostic_t orig_diag_kind,
-                                diagnostic_t diag_kind) const
-  {
-    if (!m_option_mgr)
-      return nullptr;
-    return m_option_mgr->make_option_name (option_id,
-                                          orig_diag_kind,
-                                          diag_kind);
-  }
-
-  inline char *make_option_url (diagnostic_option_id option_id) const
-  {
-    if (!m_option_mgr)
-      return nullptr;
-    return m_option_mgr->make_option_url (option_id);
-  }
-
-  void
-  set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
-                     unsigned lang_mask);
-
-  unsigned get_lang_mask () const
-  {
-    return m_lang_mask;
-  }
-
-  bool diagnostic_impl (rich_location *, const diagnostics::metadata *,
-                       diagnostic_option_id, const char *,
-                       va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
-  bool diagnostic_n_impl (rich_location *, const diagnostics::metadata *,
-                         diagnostic_option_id, unsigned HOST_WIDE_INT,
-                         const char *, const char *, va_list *,
-                         diagnostic_t) ATTRIBUTE_GCC_DIAG(7,0);
-
-  int get_diagnostic_nesting_level () const
-  {
-    return m_diagnostic_groups.m_diagnostic_nesting_level;
-  }
-
-  char *build_indent_prefix () const;
-
-  int
-  pch_save (FILE *f)
-  {
-    return m_option_classifier.pch_save (f);
-  }
-
-  int
-  pch_restore (FILE *f)
-  {
-    return m_option_classifier.pch_restore (f);
-  }
-
-
-  void set_diagnostic_buffer (diagnostics::buffer *);
-  diagnostics::buffer *get_diagnostic_buffer () const
-  {
-    return m_diagnostic_buffer;
-  }
-  void clear_diagnostic_buffer (diagnostics::buffer &);
-  void flush_diagnostic_buffer (diagnostics::buffer &);
-
-  std::unique_ptr<pretty_printer> clone_printer () const
-  {
-    return m_reference_printer->clone ();
-  }
-
-  pretty_printer *get_reference_printer () const
-  {
-    return m_reference_printer;
-  }
-
-  void
-  add_sink (std::unique_ptr<diagnostics::sink>);
-
-  void remove_all_output_sinks ();
-
-  bool supports_fnotice_on_stderr_p () const;
-
-  /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher.  */
-  void
-  set_abort_on_error (bool val)
-  {
-    m_abort_on_error = val;
-  }
-
-  /* Accessor for use in serialization, e.g. by C++ modules.  */
-  auto &
-  get_classification_history ()
-  {
-    return m_option_classifier.m_classification_history;
-  }
-
-  void set_main_input_filename (const char *filename);
-
-  void
-  set_permissive_option (diagnostic_option_id opt_permissive)
-  {
-    m_opt_permissive = opt_permissive;
-  }
-
-  void
-  set_fatal_errors (bool fatal_errors)
-  {
-    m_fatal_errors = fatal_errors;
-  }
-
-  void
-  set_internal_error_callback (void (*cb) (diagnostic_context *,
-                                          const char *,
-                                          va_list *))
-  {
-    m_internal_error = cb;
-  }
-
-  void
-  set_adjust_diagnostic_info_callback (void (*cb) (diagnostic_context *,
-                                                  diagnostic_info *))
-  {
-    m_adjust_diagnostic_info = cb;
-  }
-
-  void
-  inhibit_notes () { m_inhibit_notes_p = true; }
-
-private:
-  void error_recursion () ATTRIBUTE_NORETURN;
-
-  bool diagnostic_enabled (diagnostic_info *diagnostic);
-
-  void get_any_inlining_info (diagnostic_info *diagnostic);
-
-  void check_max_errors (bool flush);
-  void action_after_output (diagnostic_t diag_kind);
-
-  /* Data members.
-     Ideally, all of these would be private.  */
-
-private:
-  /* A reference instance of pretty_printer created by the client
-     and owned by the context.  Used for cloning when creating/adding
-     output formats.
-     Owned by the context; this would be a std::unique_ptr if
-     diagnostic_context had a proper ctor.  */
-  pretty_printer *m_reference_printer;
-
-  /* Cache of source code.
-     Owned by the context; this would be a std::unique_ptr if
-     diagnostic_context had a proper ctor.  */
-  file_cache *m_file_cache;
-
-  /* The number of times we have issued diagnostics.  */
-  diagnostic_counters m_diagnostic_counters;
-
-  /* True if it has been requested that warnings be treated as errors.  */
-  bool m_warning_as_error_requested;
-
-  /* The number of option indexes that can be passed to warning() et
-     al.  */
-  int m_n_opts;
-
-  /* The stack of sets of overridden diagnostic option severities.  */
-  diagnostic_option_classifier m_option_classifier;
-
-  /* True if we should print any CWE identifiers associated with
-     diagnostics.  */
-  bool m_show_cwe;
-
-  /* True if we should print any rules associated with diagnostics.  */
-  bool m_show_rules;
-
-  /* How should diagnostics::paths::path objects be printed.  */
-  enum diagnostic_path_format m_path_format;
-
-  /* True if we should print stack depths when printing diagnostic paths.  */
-  bool m_show_path_depths;
-
-  /* True if we should print the command line option which controls
-     each diagnostic, if known.  */
-  bool m_show_option_requested;
-
-  /* True if we should raise a SIGABRT on errors.  */
-  bool m_abort_on_error;
-
-public:
-  /* True if we should show the column number on diagnostics.  */
-  bool m_show_column;
-
-  /* True if pedwarns are errors.  */
-  bool m_pedantic_errors;
-
-  /* True if permerrors are warnings.  */
-  bool m_permissive;
-
-private:
-  /* The option to associate with turning permerrors into warnings,
-     if any.  */
-  diagnostic_option_id m_opt_permissive;
-
-  /* True if errors are fatal.  */
-  bool m_fatal_errors;
-
-public:
-  /* True if all warnings should be disabled.  */
-  bool m_inhibit_warnings;
-
-  /* True if warnings should be given in system headers.  */
-  bool m_warn_system_headers;
-
-private:
-  /* Maximum number of errors to report.  */
-  int m_max_errors;
-
-  /* Client-supplied callbacks for use in text output.  */
-  struct {
-    /* This function is called before any message is printed out.  It is
-       responsible for preparing message prefix and such.  For example, it
-       might say:
-       In file included from "/usr/local/include/curses.h:5:
-       from "/home/gdr/src/nifty_printer.h:56:
-       ...
-    */
-    diagnostic_text_starter_fn m_begin_diagnostic;
-
-    /* This function is called by diagnostic_show_locus in between
-       disjoint spans of source code, so that the context can print
-       something to indicate that a new span of source code has begun.  */
-    diagnostic_start_span_fn<to_text> m_text_start_span;
-    diagnostic_start_span_fn<to_html> m_html_start_span;
-
-    /* This function is called after the diagnostic message is printed.  */
-    diagnostic_text_finalizer_fn m_end_diagnostic;
-  } m_text_callbacks;
-
-  /* Client hook to report an internal error.  */
-  void (*m_internal_error) (diagnostic_context *, const char *, va_list *);
-
-  /* Client hook to adjust properties of the given diagnostic that we're
-     about to issue, such as its kind.  */
-  void (*m_adjust_diagnostic_info)(diagnostic_context *, diagnostic_info *);
-
-  /* Owned by the context; this would be a std::unique_ptr if
-     diagnostic_context had a proper ctor.  */
-  diagnostic_option_manager *m_option_mgr;
-  unsigned m_lang_mask;
-
-  /* A stack of optional hooks for adding URLs to quoted text strings in
-     diagnostics.  Only used for the main diagnostic message.
-     Typically a single one owner by the context, but can be temporarily
-     overridden by a borrowed urlifier (e.g. on-stack).  */
-  struct urlifier_stack_node
-  {
-    urlifier *m_urlifier;
-    bool m_owned;
-  };
-  auto_vec<urlifier_stack_node> *m_urlifier_stack;
-
-public:
-  /* Auxiliary data for client.  */
-  void *m_client_aux_data;
-
-  /* Used to detect that the last caret was printed at the same location.  */
-  location_t m_last_location;
-
-private:
-  int m_lock;
-
-  bool m_inhibit_notes_p;
-
-public:
-  diagnostic_source_printing_options m_source_printing;
-
-private:
-  /* True if -freport-bug option is used.  */
-  bool m_report_bug;
-
-  /* Used to specify additional diagnostic output to be emitted after the
-     rest of the diagnostic.  This is for implementing
-     -fdiagnostics-parseable-fixits and GCC_EXTRA_DIAGNOSTIC_OUTPUT.  */
-  enum diagnostics_extra_output_kind m_extra_output_kind;
-
-public:
-  /* What units to use when outputting the column number.  */
-  enum diagnostics_column_unit m_column_unit;
-
-  /* The origin for the column number (1-based or 0-based typically).  */
-  int m_column_origin;
-
-  /* The size of the tabstop for tab expansion.  */
-  int m_tabstop;
-
-private:
-  /* How should non-ASCII/non-printable bytes be escaped when
-     a diagnostic suggests escaping the source code on output.  */
-  enum diagnostics_escape_format m_escape_format;
-
-  /* If non-NULL, an edit_context to which fix-it hints should be
-     applied, for generating patches.
-     Owned by the context; this would be a std::unique_ptr if
-     diagnostic_context had a proper ctor.  */
-  diagnostics::edit_context *m_edit_context_ptr;
-
-  /* Fields relating to diagnostic groups.  */
-  struct {
-    /* How many diagnostic_group instances are currently alive.  */
-    int m_group_nesting_depth;
-
-    /* How many nesting levels have been pushed within this group.  */
-    int m_diagnostic_nesting_level;
-
-    /* How many diagnostics have been emitted since the bottommost
-       diagnostic_group was pushed.  */
-    int m_emission_count;
-
-    /* The "group+diagnostic" nesting depth from which to inhibit notes.  */
-    int m_inhibiting_notes_from;
-  } m_diagnostic_groups;
-
-  void inhibit_notes_in_group (bool inhibit = true);
-  bool notes_inhibited_in_group () const;
-
-  /* The various sinks to which diagnostics are to be outputted
-     (text vs structured formats such as SARIF).
-     The sinks are owned by the context; this would be a
-     std::vector<std::unique_ptr> if diagnostic_context had a
-     proper ctor.  */
-  auto_vec<diagnostics::sink *> m_sinks;
-
-  /* Callback to set the locations of call sites along the inlining
-     stack corresponding to a diagnostic location.  Needed to traverse
-     the BLOCK_SUPERCONTEXT() chain hanging off the LOCATION_BLOCK()
-     of a diagnostic's location.  */
-  set_locations_callback_t m_set_locations_cb;
-
-  /* A bundle of hooks for providing data to the context about its client
-     e.g. version information, plugins, etc.
-     Used by SARIF output to give metadata about the client that's
-     producing diagnostics.
-     Owned by the context; this would be a std::unique_ptr if
-     diagnostic_context had a proper ctor.  */
-  diagnostics::client_data_hooks *m_client_data_hooks;
-
-  /* Support for diagrams.  */
-  struct
-  {
-    /* Theme to use when generating diagrams.
-       Can be NULL (if text art is disabled).
-       Owned by the context; this would be a std::unique_ptr if
-       diagnostic_context had a proper ctor.  */
-    text_art::theme *m_theme;
-
-  } m_diagrams;
-
-  /* Owned by the context.  */
-  char **m_original_argv;
-
-  /* Borrowed pointer to the active diagnostics::buffer, if any.
-     If null (the default), then diagnostics that are reported to the
-     context are immediately issued to the output format.
-     If non-null, then diagnostics that are reported to the context
-     are buffered in the buffer, and may be issued to the output format
-     later (if the buffer is flushed), moved to other buffers, or
-     discarded (if the buffer is cleared).  */
-  diagnostics::buffer *m_diagnostic_buffer;
-};
-
-/* Client supplied function to announce a diagnostic
-   (for text-based diagnostic output).  */
-inline diagnostic_text_starter_fn &
-diagnostic_text_starter (diagnostic_context *context)
-{
-  return context->m_text_callbacks.m_begin_diagnostic;
-}
-
-/* Client supplied function called between disjoint spans of source code,
-   so that the context can print
-   something to indicate that a new span of source code has begun.  */
-inline diagnostic_start_span_fn<to_text> &
-diagnostic_start_span (diagnostic_context *context)
-{
-  return context->m_text_callbacks.m_text_start_span;
-}
-
-/* Client supplied function called after a diagnostic message is
-   displayed (for text-based diagnostic output).  */
-inline diagnostic_text_finalizer_fn &
-diagnostic_text_finalizer (diagnostic_context *context)
-{
-  return context->m_text_callbacks.m_end_diagnostic;
-}
+#include "diagnostics/context.h"
 
 /* Extension hooks for client.  */
 #define diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data
 #define diagnostic_info_auxiliary_data(DI) (DI)->m_x_data
 
-/* This diagnostic_context is used by front-ends that directly output
+/* This diagnostics::context is used by front-ends that directly output
    diagnostic messages without going through `error', `warning',
    and similar functions.  */
-extern diagnostic_context *global_dc;
+extern diagnostics::context *global_dc;
 
 /* The number of errors that have been issued so far.  Ideally, these
-   would take a diagnostic_context as an argument.  */
+   would take a diagnostics::context as an argument.  */
 #define errorcount global_dc->diagnostic_count (DK_ERROR)
 /* Similarly, but for warnings.  */
 #define warningcount global_dc->diagnostic_count (DK_WARNING)
@@ -1151,32 +194,32 @@ diagnostic_set_option_id (diagnostic_info *info,
 /* Diagnostic related functions.  */
 
 inline void
-diagnostic_initialize (diagnostic_context *context, int n_opts)
+diagnostic_initialize (diagnostics::context *context, int n_opts)
 {
   context->initialize (n_opts);
 }
 
 inline void
-diagnostic_color_init (diagnostic_context *context, int value = -1)
+diagnostic_color_init (diagnostics::context *context, int value = -1)
 {
   context->color_init (value);
 }
 
 inline void
-diagnostic_urls_init (diagnostic_context *context, int value = -1)
+diagnostic_urls_init (diagnostics::context *context, int value = -1)
 {
   context->urls_init (value);
 }
 
 inline void
-diagnostic_finish (diagnostic_context *context)
+diagnostic_finish (diagnostics::context *context)
 {
   context->finish ();
 }
 
 inline void
-diagnostic_show_locus (diagnostic_context *context,
-                      const diagnostic_source_printing_options &opts,
+diagnostic_show_locus (diagnostics::context *context,
+                      const diagnostics::source_printing_options &opts,
                       rich_location *richloc,
                       diagnostic_t diagnostic_kind,
                       pretty_printer *pp,
@@ -1189,13 +232,13 @@ diagnostic_show_locus (diagnostic_context *context,
 }
 
 inline void
-diagnostic_show_locus_as_html (diagnostic_context *context,
-                              const diagnostic_source_printing_options &opts,
+diagnostic_show_locus_as_html (diagnostics::context *context,
+                              const diagnostics::source_printing_options &opts,
                               rich_location *richloc,
                               diagnostic_t diagnostic_kind,
                               xml::printer &xp,
                               diagnostics::source_effect_info *effect_info = nullptr,
-                              html_label_writer *label_writer = nullptr)
+                              diagnostics::html_label_writer *label_writer = nullptr)
 {
   gcc_assert (context);
   gcc_assert (richloc);
@@ -1219,7 +262,7 @@ diagnostic_show_locus_as_html (diagnostic_context *context,
    rather skipped as part of the conversion process.)  */
 
 inline void
-diagnostic_initialize_input_context (diagnostic_context *context,
+diagnostic_initialize_input_context (diagnostics::context *context,
                                     diagnostic_input_charset_callback ccb,
                                     bool should_skip_bom)
 {
@@ -1228,7 +271,7 @@ diagnostic_initialize_input_context (diagnostic_context *context,
 
 /* Force diagnostics controlled by OPTIDX to be kind KIND.  */
 inline diagnostic_t
-diagnostic_classify_diagnostic (diagnostic_context *context,
+diagnostic_classify_diagnostic (diagnostics::context *context,
                                diagnostic_option_id option_id,
                                diagnostic_t kind,
                                location_t where)
@@ -1237,13 +280,13 @@ diagnostic_classify_diagnostic (diagnostic_context *context,
 }
 
 inline void
-diagnostic_push_diagnostics (diagnostic_context *context,
+diagnostic_push_diagnostics (diagnostics::context *context,
                             location_t where)
 {
   context->push_diagnostics (where);
 }
 inline void
-diagnostic_pop_diagnostics (diagnostic_context *context,
+diagnostic_pop_diagnostics (diagnostics::context *context,
                            location_t where)
 {
   context->pop_diagnostics (where);
@@ -1257,7 +300,7 @@ diagnostic_pop_diagnostics (diagnostic_context *context,
    Return true if a diagnostic was printed, false otherwise.  */
 
 inline bool
-diagnostic_report_diagnostic (diagnostic_context *context,
+diagnostic_report_diagnostic (diagnostics::context *context,
                              diagnostic_info *diagnostic)
 {
   context->begin_group ();
@@ -1280,7 +323,7 @@ namespace diagnostics {
 void default_text_starter (diagnostics::text_sink &,
                           const diagnostic_info *);
 template <typename Sink>
-void default_start_span_fn (const diagnostic_location_print_policy &,
+void default_start_span_fn (const diagnostics::location_print_policy &,
                            Sink &sink,
                            expanded_location);
 void default_text_finalizer (diagnostics::text_sink &,
@@ -1288,7 +331,7 @@ void default_text_finalizer (diagnostics::text_sink &,
                             diagnostic_t);
 } // namespace diagnostics
 
-void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
+void diagnostic_set_caret_max_width (diagnostics::context *context, int value);
 
 int get_terminal_width (void);
 
@@ -1329,8 +372,8 @@ const int CARET_LINE_MARGIN = 10;
    whether to print one or two caret lines.  */
 
 inline bool
-diagnostic_same_line (const diagnostic_context *context,
-                      expanded_location s1, expanded_location s2)
+diagnostic_same_line (const diagnostics::context *context,
+                     expanded_location s1, expanded_location s2)
 {
   return (s2.column && s1.line == s2.line
          && (context->m_source_printing.max_width - CARET_LINE_MARGIN
index 8a9353eb36e4e7fd9c66b2d8757bc4db11f83999..3ab0fce54da58d7b7893115f28a31fd5004573e7 100644 (file)
@@ -30,12 +30,12 @@ class sink;
   class text_sink;
 
 /* Class representing a buffer of zero or more diagnostics that
-   have been reported to a diagnostic_context, but which haven't
+   have been reported to a diagnostics::context, but which haven't
    yet been flushed.
 
    A diagnostics::buffer can be:
 
-   * flushed to the diagnostic_context, which issues
+   * flushed to the diagnostics::context, which issues
    the diagnostics within the buffer to the output format
    and checks for limits such as -fmax-errors=, or
 
@@ -49,18 +49,18 @@ class sink;
 
    Since a buffer needs to contain output-format-specific data,
    it's not possible to change the output format of the
-   diagnostic_context once any buffers are non-empty.
+   diagnostics::context once any buffers are non-empty.
 
    To simplify implementing output formats, it's not possible
-   to change buffering on a diagnostic_context whilst within a
+   to change buffering on a diagnostics::context whilst within a
    diagnostic group.  */
 
 class buffer
 {
  public:
-  friend class ::diagnostic_context;
+  friend class context;
 
-  buffer (diagnostic_context &ctxt);
+  buffer (context &ctxt);
   ~buffer ();
 
   void dump (FILE *out, int indent) const;
@@ -78,11 +78,11 @@ class buffer
  private:
   void ensure_per_sink_buffers ();
 
-  diagnostic_context &m_ctxt;
+  context &m_ctxt;
   auto_vec<per_sink_buffer *> *m_per_sink_buffers;
 
   /* The number of buffered diagnostics of each kind.  */
-  diagnostic_counters m_diagnostic_counters;
+  counters m_diagnostic_counters;
 };
 
 /* Implementation detail of diagnostics::buffer.
index 139173f17a947e0c2d014b79b0c0015dfb8e8f27..94c51b28190a003a4dda25d38c320dceccf5e4b0 100644 (file)
@@ -28,7 +28,7 @@ namespace diagnostics {
 class sarif_object;
 class client_version_info;
 
-/* A bundle of additional metadata, owned by the diagnostic_context,
+/* A bundle of additional metadata, owned by the diagnostics::context,
    for querying things about the client, like version data.  */
 
 class client_data_hooks
@@ -62,7 +62,7 @@ class client_data_hooks
 
 class client_plugin_info;
 
-/* Abstract base class for a diagnostic_context to get at
+/* Abstract base class for a diagnostics::context to get at
    version information about the client.  */
 
 class client_version_info
@@ -95,7 +95,7 @@ public:
   virtual void for_each_plugin (plugin_visitor &v) const = 0;
 };
 
-/* Abstract base class for a diagnostic_context to get at
+/* Abstract base class for a diagnostics::context to get at
    information about a specific plugin within a client.  */
 
 class client_plugin_info
diff --git a/gcc/diagnostics/context.h b/gcc/diagnostics/context.h
new file mode 100644 (file)
index 0000000..2168843
--- /dev/null
@@ -0,0 +1,988 @@
+/* Declare diagnostics::context and related types.
+   Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+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_DIAGNOSTICS_CONTEXT_H
+#define GCC_DIAGNOSTICS_CONTEXT_H
+
+namespace diagnostics {
+
+/*  Forward declarations.  */
+class context;
+class location_print_policy;
+class source_print_policy;
+
+typedef void (*text_starter_fn) (text_sink &,
+                                const diagnostic_info *);
+
+struct to_text;
+struct to_html;
+
+extern pretty_printer *get_printer (to_text &);
+
+template <typename Sink>
+using start_span_fn = void (*) (const location_print_policy &,
+                               Sink &sink,
+                               expanded_location);
+
+typedef void (*text_finalizer_fn) (text_sink &,
+                                  const diagnostic_info *,
+                                  diagnostic_t);
+
+/* Abstract base class for the diagnostic subsystem to make queries
+   about command-line options.  */
+
+class option_manager
+{
+public:
+  virtual ~option_manager () {}
+
+  /* Return 1 if option OPTION_ID is enabled, 0 if it is disabled,
+     or -1 if it isn't a simple on-off switch
+     (or if the value is unknown, typically set later in target).  */
+  virtual int option_enabled_p (diagnostic_option_id option_id) const = 0;
+
+  /* Return malloced memory for the name of the option OPTION_ID
+     which enabled a diagnostic, originally of type ORIG_DIAG_KIND but
+     possibly converted to DIAG_KIND by options such as -Werror.
+     May return NULL if no name is to be printed.
+     May be passed 0 as well as the index of a particular option.  */
+  virtual char *make_option_name (diagnostic_option_id option_id,
+                                 diagnostic_t orig_diag_kind,
+                                 diagnostic_t diag_kind) const = 0;
+
+  /* Return malloced memory for a URL describing the option that controls
+     a diagnostic.
+     May return NULL if no URL is available.
+     May be passed 0 as well as the index of a particular option.  */
+  virtual char *make_option_url (diagnostic_option_id option_id) const = 0;
+};
+
+/* A stack of sets of classifications: each entry in the stack is
+   a mapping from option index to diagnostic severity that can be changed
+   via pragmas.  The stack can be pushed and popped.  */
+
+class option_classifier
+{
+public:
+  void init (int n_opts);
+  void fini ();
+
+  /* Save all diagnostic classifications in a stack.  */
+  void push ();
+
+  /* Restore the topmost classification set off the stack.  If the stack
+     is empty, revert to the state based on command line parameters.  */
+  void pop (location_t where);
+
+  bool option_unspecified_p (diagnostic_option_id option_id) const
+  {
+    return get_current_override (option_id) == DK_UNSPECIFIED;
+  }
+
+  diagnostic_t get_current_override (diagnostic_option_id option_id) const
+  {
+    gcc_assert (option_id.m_idx < m_n_opts);
+    return m_classify_diagnostic[option_id.m_idx];
+  }
+
+  diagnostic_t
+  classify_diagnostic (const context *context,
+                      diagnostic_option_id option_id,
+                      diagnostic_t new_kind,
+                      location_t where);
+
+  diagnostic_t
+  update_effective_level_from_pragmas (diagnostic_info *diagnostic) const;
+
+  int pch_save (FILE *);
+  int pch_restore (FILE *);
+
+private:
+  /* Each time a diagnostic's classification is changed with a pragma,
+     we record the change and the location of the change in an array of
+     these structs.  */
+  struct classification_change_t
+  {
+    location_t location;
+
+    /* For DK_POP, this is the index of the corresponding push (as stored
+       in m_push_list).
+       Otherwise, this is an option index.  */
+    int option;
+
+    diagnostic_t kind;
+  };
+
+  int m_n_opts;
+
+  /* For each option index that can be passed to warning() et al
+     (OPT_* from options.h when using this code with the core GCC
+     options), this array may contain a new kind that the diagnostic
+     should be changed to before reporting, or DK_UNSPECIFIED to leave
+     it as the reported kind, or DK_IGNORED to not report it at
+     all.  */
+  diagnostic_t *m_classify_diagnostic;
+
+  /* History of all changes to the classifications above.  This list
+     is stored in location-order, so we can search it, either
+     binary-wise or end-to-front, to find the most recent
+     classification for a given diagnostic, given the location of the
+     diagnostic.  */
+  vec<classification_change_t> m_classification_history;
+
+  /* For context::get_classification_history, declared later.  */
+  friend class context;
+
+  /* For pragma push/pop.  */
+  vec<int> m_push_list;
+};
+
+/* A bundle of options relating to printing the user's source code
+   (potentially with a margin, underlining, labels, etc).  */
+
+struct source_printing_options
+{
+  /* True if we should print the source line with a caret indicating
+     the location.
+     Corresponds to -fdiagnostics-show-caret.  */
+  bool enabled;
+
+  /* Maximum width of the source line printed.  */
+  int max_width;
+
+  /* Character used at the caret when printing source locations.  */
+  char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
+
+  /* When printing source code, should the characters at carets and ranges
+     be colorized? (assuming colorization is on at all).
+     This should be true for frontends that generate range information
+     (so that the ranges of code are colorized),
+     and false for frontends that merely specify points within the
+     source code (to avoid e.g. colorizing just the first character in
+     a token, which would look strange).  */
+  bool colorize_source_p;
+
+  /* When printing source code, should labelled ranges be printed?
+     Corresponds to -fdiagnostics-show-labels.  */
+  bool show_labels_p;
+
+  /* When printing source code, should there be a left-hand margin
+     showing line numbers?
+     Corresponds to -fdiagnostics-show-line-numbers.  */
+  bool show_line_numbers_p;
+
+  /* If printing source code, what should the minimum width of the margin
+     be?  Line numbers will be right-aligned, and padded to this width.
+     Corresponds to -fdiagnostics-minimum-margin-width=VALUE.  */
+  int min_margin_width;
+
+  /* Usable by plugins; if true, print a debugging ruler above the
+     source output.  */
+  bool show_ruler_p;
+
+  /* When printing events in an inline path, should we print lines
+     visualizing links between related events (e.g. for CFG paths)?
+     Corresponds to -fdiagnostics-show-event-links.  */
+  bool show_event_links_p;
+};
+
+/* A bundle of state for determining column numbers in diagnostics
+   (tab stops, whether to start at 0 or 1, etc).
+   Uses a file_cache to handle tabs.  */
+
+class column_policy
+{
+public:
+  column_policy (const context &dc);
+
+  int converted_column (expanded_location s) const;
+
+  label_text get_location_text (const expanded_location &s,
+                               bool show_column,
+                               bool colorize) const;
+
+  int get_tabstop () const { return m_tabstop; }
+
+private:
+  file_cache &m_file_cache;
+  enum diagnostics_column_unit m_column_unit;
+  int m_column_origin;
+  int m_tabstop;
+};
+
+/* A bundle of state for printing locations within diagnostics
+   (e.g. "FILENAME:LINE:COLUMN"), to isolate the interactions between
+   context and the start_span callbacks.  */
+
+class location_print_policy
+{
+public:
+  location_print_policy (const context &dc);
+  location_print_policy (const text_sink &);
+
+  bool show_column_p () const { return m_show_column; }
+
+  const column_policy &
+  get_column_policy () const { return m_column_policy; }
+
+  void
+  print_text_span_start (const context &dc,
+                        pretty_printer &pp,
+                        const expanded_location &exploc);
+
+  void
+  print_html_span_start (const context &dc,
+                        xml::printer &xp,
+                        const expanded_location &exploc);
+
+private:
+  column_policy m_column_policy;
+  bool m_show_column;
+};
+
+/* Abstract base class for optionally supplying extra tags when writing
+   out annotation labels in HTML output.  */
+
+class html_label_writer
+{
+public:
+  virtual ~html_label_writer () {}
+  virtual void begin_label () = 0;
+  virtual void end_label () = 0;
+};
+
+/* A bundle of state for printing source within a diagnostic,
+   to isolate the interactions between context and the
+   implementation of diagnostic_show_locus.  */
+
+class source_print_policy
+{
+public:
+  source_print_policy (const context &);
+  source_print_policy (const context &,
+                      const source_printing_options &);
+
+  void
+  print (pretty_printer &pp,
+        const rich_location &richloc,
+        diagnostic_t diagnostic_kind,
+        source_effect_info *effect_info) const;
+
+  void
+  print_as_html (xml::printer &xp,
+                const rich_location &richloc,
+                diagnostic_t diagnostic_kind,
+                source_effect_info *effect_info,
+                html_label_writer *label_writer) const;
+
+  const source_printing_options &
+  get_options () const { return m_options; }
+
+  start_span_fn<to_text>
+  get_text_start_span_fn () const { return m_text_start_span_cb; }
+
+  start_span_fn<to_html>
+  get_html_start_span_fn () const { return m_html_start_span_cb; }
+
+  file_cache &
+  get_file_cache () const { return m_file_cache; }
+
+  enum diagnostics_escape_format
+  get_escape_format () const
+  {
+    return m_escape_format;
+  }
+
+  text_art::theme *
+  get_diagram_theme () const { return m_diagram_theme; }
+
+  const column_policy &get_column_policy () const
+  {
+    return m_location_policy.get_column_policy ();
+  }
+
+  const location_print_policy &get_location_policy () const
+  {
+    return m_location_policy;
+  }
+
+private:
+  const source_printing_options &m_options;
+  location_print_policy m_location_policy;
+  start_span_fn<to_text> m_text_start_span_cb;
+  start_span_fn<to_html> m_html_start_span_cb;
+  file_cache &m_file_cache;
+
+  /* Other data copied from context.  */
+  text_art::theme *m_diagram_theme;
+  enum diagnostics_escape_format m_escape_format;
+};
+
+/* A collection of counters of diagnostics, per-kind
+   (e.g. "3 errors and 1 warning"), for use by both context
+   and by diagnostics::buffer.  */
+
+struct counters
+{
+  counters ();
+
+  void dump (FILE *out, int indent) const;
+  void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
+
+  int get_count (diagnostic_t kind) const { return m_count_for_kind[kind]; }
+
+  void move_to (counters &dest);
+  void clear ();
+
+  int m_count_for_kind[DK_LAST_DIAGNOSTIC_KIND];
+};
+
+/* This class encapsulates the state of the diagnostics subsystem
+   as a whole (either directly, or via owned objects of other classes, to
+   avoid global variables).
+
+   It has responsibility for:
+   - being a central place for clients to report diagnostics
+   - reporting those diagnostics to zero or more output sinks
+     (e.g. text vs SARIF)
+   - providing a "dump" member function for a debug dump of the state of
+     the diagnostics subsytem
+   - direct vs buffered diagnostics (see class diagnostics::buffer)
+   - tracking the original argv of the program (for SARIF output)
+   - crash-handling
+
+   It delegates responsibility to various other classes:
+   - the various output sinks (instances of diagnostics::sink
+     subclasses)
+   - formatting of messages (class pretty_printer)
+   - an optional urlifier to inject URLs into formatted messages
+   - counting the number of diagnostics reported of each kind
+     (class diagnostics::counters)
+   - calling out to a option_manager to determine if
+     a particular warning is enabled or disabled
+   - tracking pragmas that enable/disable warnings in a range of
+     source code
+   - a cache for use when quoting the user's source code (class file_cache)
+   - a text_art::theme
+   - a diagnostics::edit_context for generating patches from fix-it hints
+   - diagnostics::client_data_hooks for metadata.
+
+   Try to avoid adding new responsibilities to this class itself, to avoid
+   the "blob" anti-pattern.  */
+
+class context
+{
+public:
+  /* Give access to m_text_callbacks.  */
+  // FIXME: these need updating
+  friend text_starter_fn &
+  text_starter (context *dc);
+  friend start_span_fn<to_text> &
+  start_span (context *dc);
+  friend text_finalizer_fn &
+  text_finalizer (context *dc);
+
+  friend class source_print_policy;
+  friend class text_sink;
+  friend class buffer;
+
+  typedef void (*set_locations_callback_t) (context *,
+                                           diagnostic_info *);
+
+  void initialize (int n_opts);
+  void color_init (int value);
+  void urls_init (int value);
+  void set_pretty_printer (std::unique_ptr<pretty_printer> pp);
+  void refresh_output_sinks ();
+
+  void finish ();
+
+  void dump (FILE *out) const;
+  void DEBUG_FUNCTION dump () const { dump (stderr); }
+
+  bool execution_failed_p () const;
+
+  void set_original_argv (unique_argv original_argv);
+  const char * const *get_original_argv ()
+  {
+    return const_cast<const char * const *> (m_original_argv);
+  }
+
+  void set_set_locations_callback (set_locations_callback_t cb)
+  {
+    m_set_locations_cb = cb;
+  }
+
+  void
+  initialize_input_context (diagnostic_input_charset_callback ccb,
+                           bool should_skip_bom);
+
+  void begin_group ();
+  void end_group ();
+
+  void push_nesting_level ();
+  void pop_nesting_level ();
+
+  bool warning_enabled_at (location_t loc, diagnostic_option_id option_id);
+
+  bool option_unspecified_p (diagnostic_option_id option_id) const
+  {
+    return m_option_classifier.option_unspecified_p (option_id);
+  }
+
+  bool emit_diagnostic_with_group (diagnostic_t kind,
+                                  rich_location &richloc,
+                                  const metadata *metadata,
+                                  diagnostic_option_id option_id,
+                                  const char *gmsgid, ...)
+    ATTRIBUTE_GCC_DIAG(6,7);
+  bool emit_diagnostic_with_group_va (diagnostic_t kind,
+                                     rich_location &richloc,
+                                     const metadata *metadata,
+                                     diagnostic_option_id option_id,
+                                     const char *gmsgid, va_list *ap)
+    ATTRIBUTE_GCC_DIAG(6,0);
+
+  bool report_diagnostic (diagnostic_info *);
+  void report_verbatim (text_info &);
+
+  /* Report a directed graph associated with the run as a whole
+     to any sinks that support directed graphs.  */
+  void
+  report_global_digraph (const digraphs::lazy_digraph &);
+
+  diagnostic_t
+  classify_diagnostic (diagnostic_option_id option_id,
+                      diagnostic_t new_kind,
+                      location_t where)
+  {
+    return m_option_classifier.classify_diagnostic (this,
+                                                   option_id,
+                                                   new_kind,
+                                                   where);
+  }
+
+  void push_diagnostics (location_t where ATTRIBUTE_UNUSED)
+  {
+    m_option_classifier.push ();
+  }
+  void pop_diagnostics (location_t where)
+  {
+    m_option_classifier.pop (where);
+  }
+
+  void maybe_show_locus (const rich_location &richloc,
+                        const source_printing_options &opts,
+                        diagnostic_t diagnostic_kind,
+                        pretty_printer &pp,
+                        source_effect_info *effect_info);
+  void maybe_show_locus_as_html (const rich_location &richloc,
+                                const source_printing_options &opts,
+                                diagnostic_t diagnostic_kind,
+                                xml::printer &xp,
+                                source_effect_info *effect_info,
+                                html_label_writer *label_writer);
+
+  void emit_diagram (const diagram &diag);
+
+  /* Various setters for use by option-handling logic.  */
+  void set_sink (std::unique_ptr<sink> sink_);
+  void set_text_art_charset (enum diagnostic_text_art_charset charset);
+  void set_client_data_hooks (std::unique_ptr<client_data_hooks> hooks);
+
+  void push_owned_urlifier (std::unique_ptr<urlifier>);
+  void push_borrowed_urlifier (const urlifier &);
+  void pop_urlifier ();
+
+  void create_edit_context ();
+  void set_warning_as_error_requested (bool val)
+  {
+    m_warning_as_error_requested = val;
+  }
+  void set_report_bug (bool val) { m_report_bug = val; }
+  void set_extra_output_kind (enum diagnostics_extra_output_kind kind)
+  {
+    m_extra_output_kind = kind;
+  }
+  void set_show_cwe (bool val) { m_show_cwe = val;  }
+  void set_show_rules (bool val) { m_show_rules = val; }
+  void set_show_highlight_colors (bool val);
+  void set_path_format (enum diagnostic_path_format val)
+  {
+    m_path_format = val;
+  }
+  void set_show_path_depths (bool val) { m_show_path_depths = val; }
+  void set_show_option_requested (bool val) { m_show_option_requested = val; }
+  void set_max_errors (int val) { m_max_errors = val; }
+  void set_escape_format (enum diagnostics_escape_format val)
+  {
+    m_escape_format = val;
+  }
+
+  void set_format_decoder (printer_fn format_decoder);
+  void set_prefixing_rule (diagnostic_prefixing_rule_t rule);
+
+  /* Various accessors.  */
+  bool warning_as_error_requested_p () const
+  {
+    return m_warning_as_error_requested;
+  }
+  bool show_path_depths_p () const { return m_show_path_depths; }
+  sink &get_sink (size_t idx) const;
+  enum diagnostic_path_format get_path_format () const { return m_path_format; }
+  enum diagnostics_escape_format get_escape_format () const
+  {
+    return m_escape_format;
+  }
+
+  file_cache &
+  get_file_cache () const
+  {
+    gcc_assert (m_file_cache);
+    return *m_file_cache;
+  }
+
+  edit_context *get_edit_context () const
+  {
+    return m_edit_context_ptr;
+  }
+  const client_data_hooks *get_client_data_hooks () const
+  {
+    return m_client_data_hooks;
+  }
+
+  const logical_locations::manager *
+  get_logical_location_manager () const;
+
+  const urlifier *get_urlifier () const;
+
+  text_art::theme *get_diagram_theme () const { return m_diagrams.m_theme; }
+
+  int &diagnostic_count (diagnostic_t kind)
+  {
+    return m_diagnostic_counters.m_count_for_kind[kind];
+  }
+  int diagnostic_count (diagnostic_t kind) const
+  {
+    return m_diagnostic_counters.get_count (kind);
+  }
+
+  /* Option-related member functions.  */
+  inline bool option_enabled_p (diagnostic_option_id option_id) const
+  {
+    if (!m_option_mgr)
+      return true;
+    return m_option_mgr->option_enabled_p (option_id);
+  }
+
+  inline char *make_option_name (diagnostic_option_id option_id,
+                                diagnostic_t orig_diag_kind,
+                                diagnostic_t diag_kind) const
+  {
+    if (!m_option_mgr)
+      return nullptr;
+    return m_option_mgr->make_option_name (option_id,
+                                          orig_diag_kind,
+                                          diag_kind);
+  }
+
+  inline char *make_option_url (diagnostic_option_id option_id) const
+  {
+    if (!m_option_mgr)
+      return nullptr;
+    return m_option_mgr->make_option_url (option_id);
+  }
+
+  void
+  set_option_manager (std::unique_ptr<option_manager> mgr,
+                     unsigned lang_mask);
+
+  unsigned get_lang_mask () const
+  {
+    return m_lang_mask;
+  }
+
+  bool diagnostic_impl (rich_location *, const metadata *,
+                       diagnostic_option_id, const char *,
+                       va_list *, diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
+  bool diagnostic_n_impl (rich_location *, const metadata *,
+                         diagnostic_option_id, unsigned HOST_WIDE_INT,
+                         const char *, const char *, va_list *,
+                         diagnostic_t) ATTRIBUTE_GCC_DIAG(7,0);
+
+  int get_diagnostic_nesting_level () const
+  {
+    return m_diagnostic_groups.m_diagnostic_nesting_level;
+  }
+
+  char *build_indent_prefix () const;
+
+  int
+  pch_save (FILE *f)
+  {
+    return m_option_classifier.pch_save (f);
+  }
+
+  int
+  pch_restore (FILE *f)
+  {
+    return m_option_classifier.pch_restore (f);
+  }
+
+
+  void set_diagnostic_buffer (buffer *);
+  buffer *get_diagnostic_buffer () const
+  {
+    return m_diagnostic_buffer;
+  }
+  void clear_diagnostic_buffer (buffer &);
+  void flush_diagnostic_buffer (buffer &);
+
+  std::unique_ptr<pretty_printer> clone_printer () const
+  {
+    return m_reference_printer->clone ();
+  }
+
+  pretty_printer *get_reference_printer () const
+  {
+    return m_reference_printer;
+  }
+
+  void
+  add_sink (std::unique_ptr<sink>);
+
+  void remove_all_output_sinks ();
+
+  bool supports_fnotice_on_stderr_p () const;
+
+  /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher.  */
+  void
+  set_abort_on_error (bool val)
+  {
+    m_abort_on_error = val;
+  }
+
+  /* Accessor for use in serialization, e.g. by C++ modules.  */
+  auto &
+  get_classification_history ()
+  {
+    return m_option_classifier.m_classification_history;
+  }
+
+  void set_main_input_filename (const char *filename);
+
+  void
+  set_permissive_option (diagnostic_option_id opt_permissive)
+  {
+    m_opt_permissive = opt_permissive;
+  }
+
+  void
+  set_fatal_errors (bool fatal_errors)
+  {
+    m_fatal_errors = fatal_errors;
+  }
+
+  void
+  set_internal_error_callback (void (*cb) (context *,
+                                          const char *,
+                                          va_list *))
+  {
+    m_internal_error = cb;
+  }
+
+  void
+  set_adjust_diagnostic_info_callback (void (*cb) (context *,
+                                                  diagnostic_info *))
+  {
+    m_adjust_diagnostic_info = cb;
+  }
+
+  void
+  inhibit_notes () { m_inhibit_notes_p = true; }
+
+private:
+  void error_recursion () ATTRIBUTE_NORETURN;
+
+  bool diagnostic_enabled (diagnostic_info *diagnostic);
+
+  void get_any_inlining_info (diagnostic_info *diagnostic);
+
+  void check_max_errors (bool flush);
+  void action_after_output (diagnostic_t diag_kind);
+
+  /* Data members.
+     Ideally, all of these would be private.  */
+
+private:
+  /* A reference instance of pretty_printer created by the client
+     and owned by the context.  Used for cloning when creating/adding
+     output formats.
+     Owned by the context; this would be a std::unique_ptr if
+     context had a proper ctor.  */
+  pretty_printer *m_reference_printer;
+
+  /* Cache of source code.
+     Owned by the context; this would be a std::unique_ptr if
+     context had a proper ctor.  */
+  file_cache *m_file_cache;
+
+  /* The number of times we have issued diagnostics.  */
+  counters m_diagnostic_counters;
+
+  /* True if it has been requested that warnings be treated as errors.  */
+  bool m_warning_as_error_requested;
+
+  /* The number of option indexes that can be passed to warning() et
+     al.  */
+  int m_n_opts;
+
+  /* The stack of sets of overridden diagnostic option severities.  */
+  option_classifier m_option_classifier;
+
+  /* True if we should print any CWE identifiers associated with
+     diagnostics.  */
+  bool m_show_cwe;
+
+  /* True if we should print any rules associated with diagnostics.  */
+  bool m_show_rules;
+
+  /* How should diagnostics::paths::path objects be printed.  */
+  enum diagnostic_path_format m_path_format;
+
+  /* True if we should print stack depths when printing diagnostic paths.  */
+  bool m_show_path_depths;
+
+  /* True if we should print the command line option which controls
+     each diagnostic, if known.  */
+  bool m_show_option_requested;
+
+  /* True if we should raise a SIGABRT on errors.  */
+  bool m_abort_on_error;
+
+public:
+  /* True if we should show the column number on diagnostics.  */
+  bool m_show_column;
+
+  /* True if pedwarns are errors.  */
+  bool m_pedantic_errors;
+
+  /* True if permerrors are warnings.  */
+  bool m_permissive;
+
+private:
+  /* The option to associate with turning permerrors into warnings,
+     if any.  */
+  diagnostic_option_id m_opt_permissive;
+
+  /* True if errors are fatal.  */
+  bool m_fatal_errors;
+
+public:
+  /* True if all warnings should be disabled.  */
+  bool m_inhibit_warnings;
+
+  /* True if warnings should be given in system headers.  */
+  bool m_warn_system_headers;
+
+private:
+  /* Maximum number of errors to report.  */
+  int m_max_errors;
+
+  /* Client-supplied callbacks for use in text output.  */
+  struct {
+    /* This function is called before any message is printed out.  It is
+       responsible for preparing message prefix and such.  For example, it
+       might say:
+       In file included from "/usr/local/include/curses.h:5:
+       from "/home/gdr/src/nifty_printer.h:56:
+       ...
+    */
+    text_starter_fn m_begin_diagnostic;
+
+    /* This function is called by diagnostic_show_locus in between
+       disjoint spans of source code, so that the context can print
+       something to indicate that a new span of source code has begun.  */
+    start_span_fn<to_text> m_text_start_span;
+    start_span_fn<to_html> m_html_start_span;
+
+    /* This function is called after the diagnostic message is printed.  */
+    text_finalizer_fn m_end_diagnostic;
+  } m_text_callbacks;
+
+  /* Client hook to report an internal error.  */
+  void (*m_internal_error) (context *, const char *, va_list *);
+
+  /* Client hook to adjust properties of the given diagnostic that we're
+     about to issue, such as its kind.  */
+  void (*m_adjust_diagnostic_info)(context *, diagnostic_info *);
+
+  /* Owned by the context; this would be a std::unique_ptr if
+     context had a proper ctor.  */
+  option_manager *m_option_mgr;
+  unsigned m_lang_mask;
+
+  /* A stack of optional hooks for adding URLs to quoted text strings in
+     diagnostics.  Only used for the main diagnostic message.
+     Typically a single one owner by the context, but can be temporarily
+     overridden by a borrowed urlifier (e.g. on-stack).  */
+  struct urlifier_stack_node
+  {
+    urlifier *m_urlifier;
+    bool m_owned;
+  };
+  auto_vec<urlifier_stack_node> *m_urlifier_stack;
+
+public:
+  /* Auxiliary data for client.  */
+  void *m_client_aux_data;
+
+  /* Used to detect that the last caret was printed at the same location.  */
+  location_t m_last_location;
+
+private:
+  int m_lock;
+
+  bool m_inhibit_notes_p;
+
+public:
+  source_printing_options m_source_printing;
+
+private:
+  /* True if -freport-bug option is used.  */
+  bool m_report_bug;
+
+  /* Used to specify additional diagnostic output to be emitted after the
+     rest of the diagnostic.  This is for implementing
+     -fdiagnostics-parseable-fixits and GCC_EXTRA_DIAGNOSTIC_OUTPUT.  */
+  enum diagnostics_extra_output_kind m_extra_output_kind;
+
+public:
+  /* What units to use when outputting the column number.  */
+  enum diagnostics_column_unit m_column_unit;
+
+  /* The origin for the column number (1-based or 0-based typically).  */
+  int m_column_origin;
+
+  /* The size of the tabstop for tab expansion.  */
+  int m_tabstop;
+
+private:
+  /* How should non-ASCII/non-printable bytes be escaped when
+     a diagnostic suggests escaping the source code on output.  */
+  enum diagnostics_escape_format m_escape_format;
+
+  /* If non-NULL, an edit_context to which fix-it hints should be
+     applied, for generating patches.
+     Owned by the context; this would be a std::unique_ptr if
+     context had a proper ctor.  */
+  edit_context *m_edit_context_ptr;
+
+  /* Fields relating to diagnostic groups.  */
+  struct {
+    /* How many diagnostic_group instances are currently alive.  */
+    int m_group_nesting_depth;
+
+    /* How many nesting levels have been pushed within this group.  */
+    int m_diagnostic_nesting_level;
+
+    /* How many diagnostics have been emitted since the bottommost
+       diagnostic_group was pushed.  */
+    int m_emission_count;
+
+    /* The "group+diagnostic" nesting depth from which to inhibit notes.  */
+    int m_inhibiting_notes_from;
+  } m_diagnostic_groups;
+
+  void inhibit_notes_in_group (bool inhibit = true);
+  bool notes_inhibited_in_group () const;
+
+  /* The various sinks to which diagnostics are to be outputted
+     (text vs structured formats such as SARIF).
+     The sinks are owned by the context; this would be a
+     std::vector<std::unique_ptr> if context had a
+     proper ctor.  */
+  auto_vec<sink *> m_sinks;
+
+  /* Callback to set the locations of call sites along the inlining
+     stack corresponding to a diagnostic location.  Needed to traverse
+     the BLOCK_SUPERCONTEXT() chain hanging off the LOCATION_BLOCK()
+     of a diagnostic's location.  */
+  set_locations_callback_t m_set_locations_cb;
+
+  /* A bundle of hooks for providing data to the context about its client
+     e.g. version information, plugins, etc.
+     Used by SARIF output to give metadata about the client that's
+     producing diagnostics.
+     Owned by the context; this would be a std::unique_ptr if
+     context had a proper ctor.  */
+  client_data_hooks *m_client_data_hooks;
+
+  /* Support for diagrams.  */
+  struct
+  {
+    /* Theme to use when generating diagrams.
+       Can be NULL (if text art is disabled).
+       Owned by the context; this would be a std::unique_ptr if
+       context had a proper ctor.  */
+    text_art::theme *m_theme;
+
+  } m_diagrams;
+
+  /* Owned by the context.  */
+  char **m_original_argv;
+
+  /* Borrowed pointer to the active diagnostics::buffer, if any.
+     If null (the default), then diagnostics that are reported to the
+     context are immediately issued to the output format.
+     If non-null, then diagnostics that are reported to the context
+     are buffered in the buffer, and may be issued to the output format
+     later (if the buffer is flushed), moved to other buffers, or
+     discarded (if the buffer is cleared).  */
+  buffer *m_diagnostic_buffer;
+};
+
+/* Client supplied function to announce a diagnostic
+   (for text-based diagnostic output).  */
+inline text_starter_fn &
+text_starter (context *dc)
+{
+  return dc->m_text_callbacks.m_begin_diagnostic;
+}
+
+/* Client supplied function called between disjoint spans of source code,
+   so that the context can print
+   something to indicate that a new span of source code has begun.  */
+inline start_span_fn<to_text> &
+start_span (context *dc)
+{
+  return dc->m_text_callbacks.m_text_start_span;
+}
+
+/* Client supplied function called after a diagnostic message is
+   displayed (for text-based diagnostic output).  */
+inline text_finalizer_fn &
+text_finalizer (context *dc)
+{
+  return dc->m_text_callbacks.m_end_diagnostic;
+}
+
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_CONTEXT_H */
index 5b80de15a63327aa5c83e4114a830fbe29186708..0785046b5ae5abb602ec099d0f65fb15d8acab0b 100644 (file)
@@ -111,7 +111,7 @@ class html_builder
 public:
   friend class html_sink_buffer;
 
-  html_builder (diagnostic_context &context,
+  html_builder (context &dc,
                pretty_printer &pp,
                const line_maps *line_maps,
                const html_generation_options &html_gen_opts);
@@ -182,7 +182,7 @@ private:
   add_graph (const digraphs::digraph &dg,
             xml::element &parent_element);
 
-  diagnostic_context &m_context;
+  context &m_context;
   pretty_printer *m_printer;
   const line_maps *m_line_maps;
   html_generation_options m_html_gen_opts;
@@ -401,11 +401,11 @@ struct html_doctypedecl : public xml::doctypedecl
 
 /* html_builder's ctor.  */
 
-html_builder::html_builder (diagnostic_context &context,
+html_builder::html_builder (context &dc,
                            pretty_printer &pp,
                            const line_maps *line_maps,
                            const html_generation_options &html_gen_opts)
-: m_context (context),
+: m_context (dc),
   m_printer (&pp),
   m_line_maps (line_maps),
   m_html_gen_opts (html_gen_opts),
@@ -420,7 +420,7 @@ html_builder::html_builder (diagnostic_context &context,
 {
   gcc_assert (m_line_maps);
 
-  if (auto client_data_hooks = context.get_client_data_hooks ())
+  if (auto client_data_hooks = dc.get_client_data_hooks ())
     m_logical_loc_mgr = client_data_hooks->get_logical_location_manager ();
 
   m_document = std::make_unique<xml::document> ();
@@ -1086,8 +1086,8 @@ html_builder::make_element_for_diagnostic (const diagnostic_info &diagnostic,
       if (s.line)
        {
          add_labelled_value (xp, "line", "Line", std::to_string (s.line), false);
-         diagnostic_column_policy column_policy (m_context);
-         int converted_column = column_policy.converted_column (s);
+         column_policy col_policy (m_context);
+         int converted_column = col_policy.converted_column (s);
          if (converted_column >= 0)
            add_labelled_value (xp, "column", "Column",
                                std::to_string (converted_column),
@@ -1134,7 +1134,7 @@ html_builder::make_element_for_diagnostic (const diagnostic_info &diagnostic,
       html_path_label_writer event_label_writer (xp, *this, *path,
                                                 event_id_prefix);
 
-      diagnostic_source_print_policy dspp (m_context);
+      source_print_policy dspp (m_context);
       print_path_as_html (xp, *path, m_context, &event_label_writer,
                          dspp);
 
@@ -1236,7 +1236,7 @@ html_builder::make_element_for_metadata (const metadata &m)
   return span_metadata;
 }
 
-/* Implementation of diagnostic_context::m_diagrams.m_emission_cb
+/* Implementation of diagnostics::context::m_diagrams.m_emission_cb
    for HTML output.  */
 
 void
@@ -1404,11 +1404,11 @@ public:
   html_builder &get_builder () { return m_builder; }
 
 protected:
-  html_sink (diagnostic_context &context,
+  html_sink (context &dc,
             const line_maps *line_maps,
             const html_generation_options &html_gen_opts)
-  : sink (context),
-    m_builder (context, *get_printer (), line_maps, html_gen_opts),
+  : sink (dc),
+    m_builder (dc, *get_printer (), line_maps, html_gen_opts),
     m_buffer (nullptr)
   {}
 
@@ -1419,11 +1419,11 @@ protected:
 class html_file_sink : public html_sink
 {
 public:
-  html_file_sink (diagnostic_context &context,
+  html_file_sink (context &dc,
                  const line_maps *line_maps,
                  const html_generation_options &html_gen_opts,
                  output_file output_file_)
-  : html_sink (context, line_maps, html_gen_opts),
+  : html_sink (dc, line_maps, html_gen_opts),
     m_output_file (std::move (output_file_))
   {
     gcc_assert (m_output_file.get_open_file ());
@@ -1451,18 +1451,18 @@ private:
 
 /* Attempt to open BASE_FILE_NAME.html for writing.
    Return a non-null output_file,
-   or return a null output_file and complain to CONTEXT
+   or return a null output_file and complain to DC
    using LINE_MAPS.  */
 
 output_file
-open_html_output_file (diagnostic_context &context,
+open_html_output_file (context &dc,
                       line_maps *line_maps,
                       const char *base_file_name)
 {
   if (!base_file_name)
     {
       rich_location richloc (line_maps, UNKNOWN_LOCATION);
-      context.emit_diagnostic_with_group
+      dc.emit_diagnostic_with_group
        (DK_ERROR, richloc, nullptr, 0,
         "unable to determine filename for HTML output");
       return output_file ();
@@ -1475,7 +1475,7 @@ open_html_output_file (diagnostic_context &context,
   if (!outf)
     {
       rich_location richloc (line_maps, UNKNOWN_LOCATION);
-      context.emit_diagnostic_with_group
+      dc.emit_diagnostic_with_group
        (DK_ERROR, richloc, nullptr, 0,
         "unable to open %qs for HTML output: %m",
         filename.get ());
@@ -1485,13 +1485,13 @@ open_html_output_file (diagnostic_context &context,
 }
 
 std::unique_ptr<sink>
-make_html_sink (diagnostic_context &context,
+make_html_sink (context &dc,
                const line_maps &line_maps,
                const html_generation_options &html_gen_opts,
                output_file output_file_)
 {
   auto sink
-    = std::make_unique<html_file_sink> (context,
+    = std::make_unique<html_file_sink> (dc,
                                        &line_maps,
                                        html_gen_opts,
                                        std::move (output_file_));
@@ -1599,10 +1599,10 @@ private:
   class html_buffered_sink : public html_sink
   {
   public:
-    html_buffered_sink (diagnostic_context &context,
+    html_buffered_sink (context &dc,
                        const line_maps *line_maps,
                        const html_generation_options &html_gen_opts)
-    : html_sink (context, line_maps, html_gen_opts)
+    : html_sink (dc, line_maps, html_gen_opts)
     {
     }
     bool machine_readable_stderr_p () const final override
@@ -1615,7 +1615,7 @@ private:
 };
 
 /* Test of reporting a diagnostic at UNKNOWN_LOCATION to a
-   diagnostic_context and examining the generated XML document.
+   diagnostics::context and examining the generated XML document.
    Verify various basic properties. */
 
 static void
index 67a2565db94eea9a71f8fff16be0603f7b592ff8..d86bde8135485f3465b25103a251d794615ca3a2 100644 (file)
@@ -46,22 +46,22 @@ struct html_generation_options
 };
 
 extern diagnostics::output_file
-open_html_output_file (diagnostic_context &context,
+open_html_output_file (context &dc,
                       line_maps *line_maps,
                       const char *base_file_name);
 
 extern std::unique_ptr<sink>
-make_html_sink (diagnostic_context &context,
+make_html_sink (context &dc,
                const line_maps &line_maps,
                const html_generation_options &html_gen_opts,
-               diagnostics::output_file output_file_);
+               output_file output_file_);
 
 extern void
 print_path_as_html (xml::printer &xp,
-                   const diagnostics::paths::path &path,
-                   diagnostic_context &dc,
+                   const paths::path &path,
+                   context &dc,
                    html_label_writer *event_label_writer,
-                   const diagnostic_source_print_policy &dspp);
+                   const source_print_policy &dspp);
 
 } // namespace diagnostics
 
index c842f7e71406d22c18ba5018a056cd5a80cd2629..c30386f0b174168e7dd682d95e8ef97cbfc9a428 100644 (file)
@@ -129,12 +129,12 @@ test_intraprocedural_path (pretty_printer *event_pp)
                "double `free'");
 }
 
-/* Implementation of diagnostic_option_manager for which all
+/* Implementation of diagnostics::option_manager for which all
    options are disabled, for use in selftests.
    Note that this is *not* called for diagnostic_option_id (0), which
    means "always warn"  */
 
-class all_warnings_disabled : public diagnostic_option_manager
+class all_warnings_disabled : public diagnostics::option_manager
 {
 public:
   int option_enabled_p (diagnostic_option_id) const final override
index 09df417e8a62aad4b9faea9171fd02eb076eafa7..f936387933413920afc263273110099780f52bfe 100644 (file)
@@ -94,7 +94,7 @@ public:
   const char *get_filename () const { return m_filename.get (); }
 
   static output_file
-  try_to_open (diagnostic_context &context,
+  try_to_open (context &dc,
               line_maps *line_maps,
               const char *base_file_name,
               const char *extension,
index 6a468dc570c3de4e122839ee765ca9a62ae21e02..ecfa8e7ca610fc3cf150413eb09f34ac1e9d661d 100644 (file)
@@ -75,7 +75,7 @@ public:
 
     virtual std::unique_ptr<sink>
     make_sink (const context &ctxt,
-              diagnostic_context &dc,
+              diagnostics::context &dc,
               const char *unparsed_arg,
               const scheme_name_and_params &parsed_arg) const = 0;
 
@@ -148,7 +148,7 @@ public:
 
   std::unique_ptr<sink>
   make_sink (const context &ctxt,
-            diagnostic_context &dc,
+            diagnostics::context &dc,
             const char *unparsed_arg,
             const scheme_name_and_params &parsed_arg);
 
@@ -165,7 +165,7 @@ public:
 
   std::unique_ptr<sink>
   make_sink (const context &ctxt,
-            diagnostic_context &dc,
+            diagnostics::context &dc,
             const char *unparsed_arg,
             const scheme_name_and_params &parsed_arg) const final override;
 };
@@ -177,7 +177,7 @@ public:
 
   std::unique_ptr<sink>
   make_sink (const context &ctxt,
-            diagnostic_context &dc,
+            diagnostics::context &dc,
             const char *unparsed_arg,
             const scheme_name_and_params &parsed_arg) const final override;
 
@@ -197,7 +197,7 @@ public:
 
   std::unique_ptr<sink>
   make_sink (const context &ctxt,
-            diagnostic_context &dc,
+            diagnostics::context &dc,
             const char *unparsed_arg,
             const scheme_name_and_params &parsed_arg) const final override;
 };
@@ -306,7 +306,7 @@ parse (const context &ctxt, const char *unparsed_arg)
 
 std::unique_ptr<sink>
 context::parse_and_make_sink (const char *unparsed_arg,
-                             diagnostic_context &dc)
+                             diagnostics::context &dc)
 {
   auto parsed_arg = parse (*this, unparsed_arg);
   if (!parsed_arg)
@@ -338,7 +338,7 @@ output_factory::get_scheme_handler (const std::string &scheme_name)
 
 std::unique_ptr<sink>
 output_factory::make_sink (const context &ctxt,
-                          diagnostic_context &dc,
+                          diagnostics::context &dc,
                           const char *unparsed_arg,
                           const scheme_name_and_params &parsed_arg)
 {
@@ -363,7 +363,7 @@ output_factory::make_sink (const context &ctxt,
 
 std::unique_ptr<sink>
 text_scheme_handler::make_sink (const context &ctxt,
-                               diagnostic_context &dc,
+                               diagnostics::context &dc,
                                const char *unparsed_arg,
                                const scheme_name_and_params &parsed_arg) const
 {
@@ -424,7 +424,7 @@ text_scheme_handler::make_sink (const context &ctxt,
 
 std::unique_ptr<sink>
 sarif_scheme_handler::make_sink (const context &ctxt,
-                                diagnostic_context &dc,
+                                diagnostics::context &dc,
                                 const char *unparsed_arg,
                                 const scheme_name_and_params &parsed_arg) const
 {
@@ -553,7 +553,7 @@ make_sarif_serialization_object (enum sarif_serialization_kind kind)
 
 std::unique_ptr<sink>
 html_scheme_handler::make_sink (const context &ctxt,
-                               diagnostic_context &dc,
+                               diagnostics::context &dc,
                                const char *unparsed_arg,
                                const scheme_name_and_params &parsed_arg) const
 {
@@ -692,7 +692,7 @@ struct parser_test
   class test_spec_context : public diagnostics::output_spec::dc_spec_context
   {
   public:
-    test_spec_context (diagnostic_context &dc,
+    test_spec_context (diagnostics::context &dc,
                       line_maps *location_mgr,
                       location_t loc,
                       const char *option_name)
index 9212efd7f0620be62185df8b6982d2f1d62c85ac..111e5aba6bac24fd77fd88eb0c136a184e0b42a4 100644 (file)
@@ -35,7 +35,7 @@ class context
  public:
   std::unique_ptr<sink>
   parse_and_make_sink (const char *,
-                      diagnostic_context &dc);
+                      diagnostics::context &dc);
 
   void
   report_error (const char *gmsgid, ...) const
@@ -82,12 +82,12 @@ protected:
   line_maps *m_affected_location_mgr;
 };
 
-/* A subclass that implements reporting errors via a diagnostic_context.  */
+/* A subclass that implements reporting errors via a diagnostics::context.  */
 
 struct dc_spec_context : public output_spec::context
 {
 public:
-  dc_spec_context (diagnostic_context &dc,
+  dc_spec_context (diagnostics::context &dc,
                   line_maps *affected_location_mgr,
                   line_maps *control_location_mgr,
                   location_t loc,
@@ -107,7 +107,7 @@ public:
     m_dc.end_group ();
   }
 
-  diagnostic_context &m_dc;
+  diagnostics::context &m_dc;
   line_maps *m_control_location_mgr;
   location_t m_loc;
 };
index 5cf61ceb10bfe2e92e6592f5b6fa089e027af63a..c409cce14cc8f0cbc1ca072e6b2df77302c72387 100644 (file)
@@ -67,7 +67,7 @@ public:
   {
   }
 
-  path_print_policy (const diagnostic_context &dc)
+  path_print_policy (const diagnostics::context &dc)
   : m_source_policy (dc)
   {
   }
@@ -78,11 +78,11 @@ public:
     return m_source_policy.get_diagram_theme ();
   }
 
-  const diagnostic_source_print_policy &
+  const diagnostics::source_print_policy &
   get_source_policy () const { return m_source_policy; }
 
 private:
-  diagnostic_source_print_policy m_source_policy;
+  diagnostics::source_print_policy m_source_policy;
 };
 
 /* Subclass of range_label for showing a particular event
@@ -599,7 +599,7 @@ struct event_range
   {
     location_t initial_loc = m_initial_event.get_location ();
 
-    diagnostic_context &dc = text_output.get_context ();
+    diagnostics::context &dc = text_output.get_context ();
 
     /* Emit a span indicating the filename (and line/column) if the
        line has changed relative to the last call to
@@ -611,7 +611,7 @@ struct event_range
          (line_table, initial_loc, LOCATION_ASPECT_CARET);
        if (exploc.file != LOCATION_FILE (dc.m_last_location))
          {
-           diagnostic_location_print_policy loc_policy (text_output);
+           diagnostics::location_print_policy loc_policy (text_output);
            loc_policy.print_text_span_start (dc, pp, exploc);
          }
       }
@@ -653,7 +653,7 @@ struct event_range
      call to diagnostic_show_locus_as_html.  */
 
   void print_as_html (xml::printer &xp,
-                     diagnostic_context &dc,
+                     diagnostics::context &dc,
                      diagnostics::source_effect_info *effect_info,
                      html_label_writer *event_label_writer)
   {
@@ -669,7 +669,7 @@ struct event_range
          (line_table, initial_loc, LOCATION_ASPECT_CARET);
        if (exploc.file != LOCATION_FILE (dc.m_last_location))
          {
-           diagnostic_location_print_policy loc_policy (dc);
+           diagnostics::location_print_policy loc_policy (dc);
            loc_policy.print_html_span_start (dc, xp, exploc);
          }
       }
@@ -1044,7 +1044,7 @@ public:
   }
 
   void
-  print_swimlane_for_event_range_as_html (diagnostic_context &dc,
+  print_swimlane_for_event_range_as_html (diagnostics::context &dc,
                                          xml::printer &xp,
                                          html_label_writer *event_label_writer,
                                          event_range *range,
@@ -1152,7 +1152,7 @@ print_path_summary_as_text (const path_summary &ps,
 
 static void
 print_path_summary_as_html (const path_summary &ps,
-                           diagnostic_context &dc,
+                           diagnostics::context &dc,
                            xml::printer &xp,
                            html_label_writer *event_label_writer,
                            bool show_depths)
@@ -1385,14 +1385,14 @@ diagnostics::text_sink::print_path (const path &path_)
 void
 diagnostics::print_path_as_html (xml::printer &xp,
                                 const path &path_,
-                                diagnostic_context &dc,
+                                context &dc,
                                 html_label_writer *event_label_writer,
-                                const diagnostic_source_print_policy &dspp)
+                                const source_print_policy &dspp)
 {
   path_print_policy policy (dc);
   const bool check_rich_locations = true;
   const bool colorize = false;
-  const diagnostic_source_printing_options &source_printing_opts
+  const source_printing_options &source_printing_opts
     = dspp.get_options ();
   const bool show_event_links = source_printing_opts.show_event_links_p;
   path_summary summary (policy,
index fddf3dbdc456e6c99b05cf224b658585a2d4b7e7..228917286bec82e7eb70277ecb38d3106351e576 100644 (file)
@@ -753,7 +753,7 @@ class sarif_builder
 public:
   friend class sarif_sink_buffer;
 
-  sarif_builder (diagnostic_context &context,
+  sarif_builder (diagnostics::context &dc,
                 pretty_printer &printer,
                 const line_maps *line_maps,
                 std::unique_ptr<sarif_serialization_format> serialization_format,
@@ -820,7 +820,7 @@ public:
     return m_current_code_flow;
   }
 
-  diagnostic_context &get_context () const { return m_context; }
+  diagnostics::context &get_context () const { return m_context; }
   pretty_printer *get_printer () const { return m_printer; }
   token_printer &get_token_printer () { return m_token_printer; }
   enum sarif_version get_version () const { return m_sarif_gen_opts.m_version; }
@@ -950,7 +950,7 @@ private:
   std::unique_ptr<json::object>
   make_stack_from_backtrace ();
 
-  diagnostic_context &m_context;
+  diagnostics::context &m_context;
   pretty_printer *m_printer;
   const line_maps *m_line_maps;
   sarif_token_printer m_token_printer;
@@ -1062,10 +1062,10 @@ sarif_invocation::add_notification_for_ice (const diagnostic_info &diagnostic,
 void
 sarif_invocation::prepare_to_flush (sarif_builder &builder)
 {
-  const diagnostic_context &context = builder.get_context ();
+  const context &dc = builder.get_context ();
 
   /* "executionSuccessful" property (SARIF v2.1.0 section 3.20.14).  */
-  if (context.execution_failed_p ())
+  if (dc.execution_failed_p ())
     m_success = false;
   set_bool ("executionSuccessful", m_success);
 
@@ -1074,7 +1074,7 @@ sarif_invocation::prepare_to_flush (sarif_builder &builder)
 
   /* Call client hook, allowing it to create a custom property bag for
      this object (SARIF v2.1.0 section 3.8) e.g. for recording time vars.  */
-  if (auto client_data_hooks = context.get_client_data_hooks ())
+  if (auto client_data_hooks = dc.get_client_data_hooks ())
     client_data_hooks->add_sarif_invocation_properties (*this);
 
   // "endTimeUtc" property (SARIF v2.1.0 section 3.20.8);
@@ -1652,19 +1652,19 @@ sarif_thread_flow::add_location ()
 
 /* sarif_builder's ctor.  */
 
-sarif_builder::sarif_builder (diagnostic_context &context,
+sarif_builder::sarif_builder (diagnostics::context &dc,
                              pretty_printer &printer,
                              const line_maps *line_maps,
                              std::unique_ptr<sarif_serialization_format> serialization_format,
                              const sarif_generation_options &sarif_gen_opts)
-: m_context (context),
+: m_context (dc),
   m_printer (&printer),
   m_line_maps (line_maps),
   m_token_printer (*this),
   m_logical_loc_mgr (nullptr),
   m_invocation_obj
     (std::make_unique<sarif_invocation> (*this,
-                                        context.get_original_argv ())),
+                                        dc.get_original_argv ())),
   m_results_array (new json::array ()),
   m_cur_group_result (nullptr),
   m_seen_any_relative_paths (false),
@@ -1674,7 +1674,7 @@ sarif_builder::sarif_builder (diagnostic_context &context,
     (std::make_unique<sarif_array_of_unique<sarif_logical_location>> ()),
   m_run_graphs
     (std::make_unique<sarif_array_of_unique<sarif_graph>> ()),
-  m_tabstop (context.m_tabstop),
+  m_tabstop (dc.m_tabstop),
   m_serialization_format (std::move (serialization_format)),
   m_sarif_gen_opts (sarif_gen_opts),
   m_next_result_idx (0),
@@ -1683,7 +1683,7 @@ sarif_builder::sarif_builder (diagnostic_context &context,
   gcc_assert (m_line_maps);
   gcc_assert (m_serialization_format);
 
-  if (auto client_data_hooks = context.get_client_data_hooks ())
+  if (auto client_data_hooks = dc.get_client_data_hooks ())
     m_logical_loc_mgr = client_data_hooks->get_logical_location_manager ();
 }
 
@@ -1883,7 +1883,7 @@ sarif_builder::on_report_diagnostic (const diagnostic_info &diagnostic,
     }
 }
 
-/* Implementation of diagnostic_context::m_diagrams.m_emission_cb
+/* Implementation of diagnostics::context::m_diagrams.m_emission_cb
    for SARIF output.  */
 
 void
@@ -2267,7 +2267,7 @@ sarif_builder::make_location_object (sarif_location_manager *loc_mgr,
     std::unique_ptr<sarif_multiformat_message_string>
     render (const sarif_builder &builder) const final override
     {
-      diagnostic_context dc;
+      diagnostics::context dc;
       diagnostic_initialize (&dc, 0);
       dc.m_source_printing.enabled = true;
       dc.m_source_printing.colorize_source_p = false;
@@ -2277,7 +2277,7 @@ sarif_builder::make_location_object (sarif_location_manager *loc_mgr,
       rich_location my_rich_loc (m_richloc);
       my_rich_loc.set_escape_on_output (true);
 
-      diagnostic_source_print_policy source_policy (dc);
+      source_print_policy source_policy (dc);
       dc.set_escape_format (m_escape_format);
       text_sink text_output (dc);
       source_policy.print (*text_output.get_printer (),
@@ -2378,7 +2378,7 @@ sarif_builder::make_location_object (sarif_location_manager *loc_mgr,
 /* If WHERE was #included from somewhere, add a worklist item
    to LOC_MGR to lazily add a location for the #include location,
    and relationships between it and the LOCATION_OBJ.
-   Compare with diagnostic_context::report_current_module, but rather
+   Compare with diagnostics::context::report_current_module, but rather
    than iterating the current chain, we add the next edge and iterate
    in the worklist, so that edges are only added once.  */
 
@@ -3940,12 +3940,12 @@ public:
   sarif_result &get_result (size_t idx) { return m_builder.get_result (idx); }
 
 protected:
-  sarif_sink (diagnostic_context &context,
+  sarif_sink (context &dc,
              const line_maps *line_maps,
              std::unique_ptr<sarif_serialization_format> serialization_format,
              const sarif_generation_options &sarif_gen_opts)
-  : sink (context),
-    m_builder (context, *get_printer (), line_maps,
+  : sink (dc),
+    m_builder (dc, *get_printer (), line_maps,
               std::move (serialization_format), sarif_gen_opts),
     m_buffer (nullptr)
   {}
@@ -3957,12 +3957,12 @@ protected:
 class sarif_stream_sink : public sarif_sink
 {
 public:
-  sarif_stream_sink (diagnostic_context &context,
+  sarif_stream_sink (context &dc,
                     const line_maps *line_maps,
                     std::unique_ptr<sarif_serialization_format> serialization_format,
                     const sarif_generation_options &sarif_gen_opts,
                     FILE *stream)
-  : sarif_sink (context, line_maps,
+  : sarif_sink (dc, line_maps,
                std::move (serialization_format), sarif_gen_opts),
     m_stream (stream)
   {
@@ -3982,12 +3982,12 @@ private:
 class sarif_file_sink : public sarif_sink
 {
 public:
-  sarif_file_sink (diagnostic_context &context,
+  sarif_file_sink (context &dc,
                   const line_maps *line_maps,
                   std::unique_ptr<sarif_serialization_format> serialization_format,
                   const sarif_generation_options &sarif_gen_opts,
                   output_file output_file_)
-  : sarif_sink (context, line_maps,
+  : sarif_sink (dc, line_maps,
                std::move (serialization_format),
                sarif_gen_opts),
     m_output_file (std::move (output_file_))
@@ -4136,7 +4136,7 @@ sarif_builder::sarif_token_printer::print_tokens (pretty_printer *pp,
    Return a reference to *FMT.  */
 
 static sink &
-init_sarif_sink (diagnostic_context &context,
+init_sarif_sink (context &dc,
                 std::unique_ptr<sarif_sink> fmt)
 {
   gcc_assert (fmt);
@@ -4144,16 +4144,16 @@ init_sarif_sink (diagnostic_context &context,
 
   fmt->update_printer ();
 
-  context.set_sink (std::move (fmt));
+  dc.set_sink (std::move (fmt));
 
   return out;
 }
 
-/* Populate CONTEXT in preparation for SARIF output to stderr.
+/* Populate DC in preparation for SARIF output to stderr.
    Return a reference to the new sink.  */
 
 sink &
-init_sarif_stderr (diagnostic_context &context,
+init_sarif_stderr (context &dc,
                   const line_maps *line_maps,
                   bool formatted)
 {
@@ -4162,8 +4162,8 @@ init_sarif_stderr (diagnostic_context &context,
   auto serialization
     = std::make_unique<sarif_serialization_format_json> (formatted);
   return init_sarif_sink
-    (context,
-     std::make_unique<sarif_stream_sink> (context,
+    (dc,
+     std::make_unique<sarif_stream_sink> (dc,
                                          line_maps,
                                          std::move (serialization),
                                          sarif_gen_opts,
@@ -4172,11 +4172,11 @@ init_sarif_stderr (diagnostic_context &context,
 
 /* Attempt to open "BASE_FILE_NAME""EXTENSION" for writing.
    Return a non-null output_file,
-   or return a null output_file and complain to CONTEXT
+   or return a null output_file and complain to DC
    using LINE_MAPS.  */
 
 output_file
-output_file::try_to_open (diagnostic_context &context,
+output_file::try_to_open (context &dc,
                          line_maps *line_maps,
                          const char *base_file_name,
                          const char *extension,
@@ -4188,7 +4188,7 @@ output_file::try_to_open (diagnostic_context &context,
   if (!base_file_name)
     {
       rich_location richloc (line_maps, UNKNOWN_LOCATION);
-      context.emit_diagnostic_with_group
+      dc.emit_diagnostic_with_group
        (DK_ERROR, richloc, nullptr, 0,
         "unable to determine filename for SARIF output");
       return output_file ();
@@ -4201,7 +4201,7 @@ output_file::try_to_open (diagnostic_context &context,
   if (!outf)
     {
       rich_location richloc (line_maps, UNKNOWN_LOCATION);
-      context.emit_diagnostic_with_group
+      dc.emit_diagnostic_with_group
        (DK_ERROR, richloc, nullptr, 0,
         "unable to open %qs for diagnostic output: %m",
         filename.get ());
@@ -4212,11 +4212,11 @@ output_file::try_to_open (diagnostic_context &context,
 
 /* Attempt to open BASE_FILE_NAME.sarif for writing JSON.
    Return a non-null output_file,
-   or return a null output_file and complain to CONTEXT
+   or return a null output_file and complain to DC
    using LINE_MAPS.  */
 
 output_file
-open_sarif_output_file (diagnostic_context &context,
+open_sarif_output_file (context &dc,
                        line_maps *line_maps,
                        const char *base_file_name,
                        enum sarif_serialization_kind serialization_kind)
@@ -4233,19 +4233,19 @@ open_sarif_output_file (diagnostic_context &context,
       break;
     }
 
-  return output_file::try_to_open (context,
+  return output_file::try_to_open (dc,
                                   line_maps,
                                   base_file_name,
                                   suffix,
                                   is_binary);
 }
 
-/* Populate CONTEXT in preparation for SARIF output to a file named
+/* Populate DC in preparation for SARIF output to a file named
    BASE_FILE_NAME.sarif.
    Return a reference to the new sink.  */
 
 sink &
-init_sarif_file (diagnostic_context &context,
+init_sarif_file (context &dc,
                 line_maps *line_maps,
                 bool formatted,
                 const char *base_file_name)
@@ -4253,7 +4253,7 @@ init_sarif_file (diagnostic_context &context,
   gcc_assert (line_maps);
 
   output_file output_file_
-    = open_sarif_output_file (context,
+    = open_sarif_output_file (dc,
                              line_maps,
                              base_file_name,
                              sarif_serialization_kind::json);
@@ -4262,19 +4262,19 @@ init_sarif_file (diagnostic_context &context,
 
   const sarif_generation_options sarif_gen_opts;
   return init_sarif_sink
-    (context,
-     std::make_unique<sarif_file_sink> (context,
+    (dc,
+     std::make_unique<sarif_file_sink> (dc,
                                        line_maps,
                                        std::move (serialization),
                                        sarif_gen_opts,
                                        std::move (output_file_)));
 }
 
-/* Populate CONTEXT in preparation for SARIF output to STREAM.
+/* Populate DC in preparation for SARIF output to STREAM.
    Return a reference to the new sink.  */
 
 sink &
-init_sarif_stream (diagnostic_context &context,
+init_sarif_stream (context &dc,
                   const line_maps *line_maps,
                   bool formatted,
                   FILE *stream)
@@ -4284,8 +4284,8 @@ init_sarif_stream (diagnostic_context &context,
   auto serialization
     = std::make_unique<sarif_serialization_format_json> (formatted);
   return init_sarif_sink
-    (context,
-     std::make_unique<sarif_stream_sink> (context,
+    (dc,
+     std::make_unique<sarif_stream_sink> (dc,
                                          line_maps,
                                          std::move (serialization),
                                          sarif_gen_opts,
@@ -4293,14 +4293,14 @@ init_sarif_stream (diagnostic_context &context,
 }
 
 std::unique_ptr<sink>
-make_sarif_sink (diagnostic_context &context,
+make_sarif_sink (context &dc,
                 const line_maps &line_maps,
                 std::unique_ptr<sarif_serialization_format> serialization,
                 const sarif_generation_options &sarif_gen_opts,
                 output_file output_file_)
 {
   auto sink
-    = std::make_unique<sarif_file_sink> (context,
+    = std::make_unique<sarif_file_sink> (dc,
                                         &line_maps,
                                         std::move (serialization),
                                         sarif_gen_opts,
@@ -4426,11 +4426,11 @@ private:
   class buffered_sink : public sarif_sink
   {
   public:
-    buffered_sink (diagnostic_context &context,
+    buffered_sink (context &dc,
                   const line_maps *line_maps,
                   bool formatted,
                   const sarif_generation_options &sarif_gen_opts)
-    : sarif_sink (context, line_maps,
+    : sarif_sink (dc, line_maps,
                  std::make_unique<sarif_serialization_format_json> (formatted),
                  sarif_gen_opts)
     {
@@ -4575,7 +4575,7 @@ test_make_location_object (const sarif_generation_options &sarif_gen_opts,
 }
 
 /* Test of reporting a diagnostic at UNKNOWN_LOCATION to a
-   diagnostic_context and examining the generated sarif_log.
+   diagnostics::context and examining the generated sarif_log.
    Verify various basic properties. */
 
 static void
index f4eda7b5fbfa1b35496cb2f183db8ed16af81a33..9f8a73fd2849374d038e882bc9ce5b75303ca022 100644 (file)
@@ -43,23 +43,23 @@ enum class sarif_serialization_kind
    num_values
 };
 
-extern diagnostics::output_file
-open_sarif_output_file (diagnostic_context &context,
+extern output_file
+open_sarif_output_file (context &dc,
                        line_maps *line_maps,
                        const char *base_file_name,
                        enum sarif_serialization_kind serialization_kind);
 
 extern sink &
-init_sarif_stderr (diagnostic_context &context,
+init_sarif_stderr (context &dc,
                   const line_maps *line_maps,
                   bool formatted);
 extern sink &
-init_sarif_file (diagnostic_context &context,
+init_sarif_file (context &dc,
                 line_maps *line_maps,
                 bool formatted,
                 const char *base_file_name);
 extern sink &
-init_sarif_stream (diagnostic_context &context,
+init_sarif_stream (context &dc,
                   const line_maps *line_maps,
                   bool formatted,
                   FILE *stream);
@@ -113,11 +113,11 @@ struct sarif_generation_options
 };
 
 extern std::unique_ptr<sink>
-make_sarif_sink (diagnostic_context &context,
+make_sarif_sink (context &dc,
                 const line_maps &line_maps,
                 std::unique_ptr<sarif_serialization_format> serialization_format,
                 const sarif_generation_options &sarif_gen_opts,
-                diagnostics::output_file output_file_);
+                output_file output_file_);
 
 class sarif_builder;
 class sarif_location_manager;
@@ -130,11 +130,11 @@ class sarif_property_bag : public json::object
 public:
   void set_logical_location (const char *property_name,
                             sarif_builder &,
-                            diagnostics::logical_locations::key logical_loc);
+                            logical_locations::key logical_loc);
   void set_graph (const char *property_name,
                  sarif_builder &,
                  sarif_location_manager *sarif_location_mgr,
-                 const diagnostics::digraphs::digraph &g);
+                 const digraphs::digraph &g);
 };
 
 /* Concrete subclass of json::object for SARIF objects that can
index 71e41330e236c52c900459ad55dd2e10b4a25b42..e8b54180806340cc83007bd8470d2d6f91b0edf0 100644 (file)
@@ -48,7 +48,7 @@ public:
   make_per_sink_buffer () = 0;
 
   /* Vfunc to be called when call a diagnostics::buffer is set on
-     a diagnostic_context, to update this format.  The per_sink_buffer
+     a diagnostics::context, to update this format.  The per_sink_buffer
      will be one created by make_per_sink_buffer above and thus be
      of the correct subclass.  */
   virtual void set_buffer (per_sink_buffer *) = 0;
@@ -68,7 +68,7 @@ public:
   virtual bool machine_readable_stderr_p () const = 0;
   virtual bool follows_reference_printer_p () const = 0;
 
-  /* Vfunc called when the diagnostic_context changes its
+  /* Vfunc called when the diagnostics::context changes its
      reference printer (either to a new subclass of pretty_printer
      or when color/url options change).
      Subclasses should update their m_printer accordingly.  */
@@ -77,7 +77,7 @@ public:
   virtual void
   report_global_digraph (const digraphs::lazy_digraph &) = 0;
 
-  diagnostic_context &get_context () const { return m_context; }
+  context &get_context () const { return m_context; }
   pretty_printer *get_printer () const { return m_printer.get (); }
 
   text_art::theme *get_diagram_theme () const
@@ -88,18 +88,18 @@ public:
   void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
 
 protected:
-  sink (diagnostic_context &context)
-  : m_context (context),
-    m_printer (context.clone_printer ())
+  sink (context &dc)
+  : m_context (dc),
+    m_printer (dc.clone_printer ())
   {}
 
 protected:
-  diagnostic_context &m_context;
+  context &m_context;
   std::unique_ptr<pretty_printer> m_printer;
 };
 
 extern void
-output_format_init (diagnostic_context &,
+output_format_init (context &,
                    const char *main_input_filename_,
                    const char *base_file_name,
                    enum diagnostics_output_format,
index 843f6712df74a71ff0a7a57714542e704578f89a..7794dc2c6715c1a0cc4f31777b6d4e5fd130728b 100644 (file)
@@ -375,9 +375,9 @@ struct char_display_policy : public cpp_char_column_policy
  public:
   char_display_policy (int tabstop,
                       int (*width_cb) (cppchar_t c),
-                      void (*print_text_cb) (to_text &sink,
+                      void (*print_text_cb) (diagnostics::to_text &sink,
                                              const cpp_decoded_char &cp),
-                      void (*print_html_cb) (to_html &sink,
+                      void (*print_html_cb) (diagnostics::to_html &sink,
                                              const cpp_decoded_char &cp))
   : cpp_char_column_policy (tabstop, width_cb),
     m_print_text_cb (print_text_cb),
@@ -385,9 +385,9 @@ struct char_display_policy : public cpp_char_column_policy
   {
   }
 
-  void (*m_print_text_cb) (to_text &sink,
+  void (*m_print_text_cb) (diagnostics::to_text &sink,
                           const cpp_decoded_char &cp);
-  void (*m_print_html_cb) (to_html &sink,
+  void (*m_print_html_cb) (diagnostics::to_html &sink,
                           const cpp_decoded_char &cp);
 };
 
@@ -395,6 +395,8 @@ template <typename Sink> class layout_printer;
 
 } // anonymous namespace
 
+namespace diagnostics {
+
 /* This code is written generically to write either:
    - text, to a pretty_printer, potentially with colorization codes, or
    - html, to an xml::printer, with nested HTML tags.
@@ -519,8 +521,8 @@ struct to_text
   }
 
   void
-  invoke_start_span_fn (const diagnostic_source_print_policy &source_policy,
-                       const diagnostic_location_print_policy &loc_policy,
+  invoke_start_span_fn (const source_print_policy &source_policy,
+                       const location_print_policy &loc_policy,
                        const expanded_location &exploc)
   {
     source_policy.get_text_start_span_fn () (loc_policy, *this, exploc);
@@ -654,8 +656,8 @@ struct to_html
   }
 
   void
-  invoke_start_span_fn (const diagnostic_source_print_policy &source_policy,
-                       const diagnostic_location_print_policy &loc_policy,
+  invoke_start_span_fn (const source_print_policy &source_policy,
+                       const location_print_policy &loc_policy,
                        const expanded_location &exploc)
   {
     source_policy.get_html_start_span_fn () (loc_policy, *this, exploc);
@@ -687,24 +689,24 @@ private:
 };
 
 void
-diagnostic_location_print_policy::
-print_text_span_start (const diagnostic_context &dc,
+location_print_policy::
+print_text_span_start (const diagnostics::context &dc,
                       pretty_printer &pp,
                       const expanded_location &exploc)
 {
   to_text sink (pp, nullptr);
-  diagnostic_source_print_policy source_policy (dc);
+  source_print_policy source_policy (dc);
   source_policy.get_text_start_span_fn () (*this, sink, exploc);
 }
 
 void
-diagnostic_location_print_policy::
-print_html_span_start (const diagnostic_context &dc,
+location_print_policy::
+print_html_span_start (const diagnostics::context &dc,
                       xml::printer &xp,
                       const expanded_location &exploc)
 {
   to_html sink (xp, nullptr, nullptr);
-  diagnostic_source_print_policy source_policy (dc);
+  source_print_policy source_policy (dc);
   source_policy.get_html_start_span_fn () (*this, sink, exploc);
 }
 
@@ -716,37 +718,38 @@ get_printer (to_text &sink)
 
 template<>
 void
-diagnostics::default_start_span_fn<to_text> (const diagnostic_location_print_policy &loc_policy,
-                                            to_text &sink,
-                                            expanded_location exploc)
+default_start_span_fn<to_text> (const location_print_policy &loc_policy,
+                               to_text &sink,
+                               expanded_location exploc)
 {
-  const diagnostic_column_policy &column_policy
-    = loc_policy.get_column_policy ();
+  const column_policy &column_policy_ = loc_policy.get_column_policy ();
   label_text text
-    = column_policy.get_location_text (exploc,
-                                      loc_policy.show_column_p (),
-                                      pp_show_color (&sink.m_pp));
+    = column_policy_.get_location_text (exploc,
+                                       loc_policy.show_column_p (),
+                                       pp_show_color (&sink.m_pp));
   pp_string (&sink.m_pp, text.get ());
   pp_newline (&sink.m_pp);
 }
 
 template<>
 void
-diagnostics::default_start_span_fn<to_html> (const diagnostic_location_print_policy &loc_policy,
-                                            to_html &sink,
-                                            expanded_location exploc)
+default_start_span_fn<to_html> (const location_print_policy &loc_policy,
+                               to_html &sink,
+                               expanded_location exploc)
 {
-  const diagnostic_column_policy &column_policy
+  const column_policy &column_policy_
     = loc_policy.get_column_policy ();
   label_text text
-    = column_policy.get_location_text (exploc,
-                                      loc_policy.show_column_p (),
-                                      false);
+    = column_policy_.get_location_text (exploc,
+                                       loc_policy.show_column_p (),
+                                       false);
   sink.m_xp.push_tag_with_class ("span", "location", true);
   sink.m_xp.add_text (text.get ());
   sink.m_xp.pop_tag ("span");
 }
 
+} // namespace diagnostics
+
 namespace {
 
 /* A class to control the overall layout when printing a diagnostic.
@@ -761,10 +764,10 @@ namespace {
 class layout
 {
  public:
-  friend class layout_printer<to_text>;
-  friend class layout_printer<to_html>;
+  friend class layout_printer<diagnostics::to_text>;
+  friend class layout_printer<diagnostics::to_html>;
 
-  layout (const diagnostic_source_print_policy &source_policy,
+  layout (const diagnostics::source_print_policy &source_policy,
          const rich_location &richloc,
          diagnostics::source_effect_info *effect_info = nullptr);
 
@@ -811,7 +814,7 @@ class layout
  private:
   bool compatible_locations_p (location_t loc_a, location_t loc_b) const;
 
-  const diagnostic_source_printing_options &m_options;
+  const diagnostics::source_printing_options &m_options;
   const line_maps *m_line_table;
   file_cache &m_file_cache;
   const text_art::ascii_theme m_fallback_theme;
@@ -847,10 +850,10 @@ public:
                  const layout &layout,
                  bool is_diagnostic_path);
 
-  void print (const diagnostic_source_print_policy &source_policy);
+  void print (const diagnostics::source_print_policy &source_policy);
 
 private:
-  const diagnostic_source_printing_options &
+  const diagnostics::source_printing_options &
   get_options () const { return m_layout.m_options; }
 
   const text_art::theme &
@@ -1693,15 +1696,15 @@ escape_as_unicode_print (Sink &sink,
 /* Populate a char_display_policy based on SOURCE_POLICY and RICHLOC.  */
 
 static char_display_policy
-make_char_policy (const diagnostic_source_print_policy &source_policy,
+make_char_policy (const diagnostics::source_print_policy &source_policy,
                  const rich_location &richloc)
 {
   /* The default is to not escape non-ASCII bytes.  */
   char_display_policy result
     (source_policy.get_column_policy ().get_tabstop (),
      cpp_wcwidth,
-     default_print_decoded_ch<to_text>,
-     default_print_decoded_ch<to_html>);
+     default_print_decoded_ch<diagnostics::to_text>,
+     default_print_decoded_ch<diagnostics::to_html>);
 
   /* If the diagnostic suggests escaping non-ASCII bytes, then
      use policy from user-supplied options.  */
@@ -1714,13 +1717,15 @@ make_char_policy (const diagnostic_source_print_policy &source_policy,
          gcc_unreachable ();
        case DIAGNOSTICS_ESCAPE_FORMAT_UNICODE:
          result.m_width_cb = escape_as_unicode_width;
-         result.m_print_text_cb = escape_as_unicode_print<to_text>;
-         result.m_print_html_cb = escape_as_unicode_print<to_html>;
+         result.m_print_text_cb
+           = escape_as_unicode_print<diagnostics::to_text>;
+         result.m_print_html_cb
+           = escape_as_unicode_print<diagnostics::to_html>;
          break;
        case DIAGNOSTICS_ESCAPE_FORMAT_BYTES:
          result.m_width_cb = escape_as_bytes_width;
-         result.m_print_text_cb = escape_as_bytes_print<to_text>;
-         result.m_print_html_cb = escape_as_bytes_print<to_html>;
+         result.m_print_text_cb = escape_as_bytes_print<diagnostics::to_text>;
+         result.m_print_html_cb = escape_as_bytes_print<diagnostics::to_html>;
          break;
        }
     }
@@ -1737,9 +1742,9 @@ make_char_policy (const diagnostic_source_print_policy &source_policy,
    Determine the range of lines that we will print, splitting them
    up into an ordered list of disjoint spans of contiguous line numbers.
    Determine m_x_offset_display, to ensure that the primary caret
-   will fit within the max_width provided by the diagnostic_context.  */
+   will fit within the max_width provided by the diagnostics::context.  */
 
-layout::layout (const diagnostic_source_print_policy &source_policy,
+layout::layout (const diagnostics::source_print_policy &source_policy,
                const rich_location &richloc,
                diagnostics::source_effect_info *effect_info)
 : m_options (source_policy.get_options ()),
@@ -1929,7 +1934,7 @@ layout::will_show_line_p (linenum_type row) const
 
 template<>
 void
-layout_printer<to_text>::print_gap_in_line_numbering ()
+layout_printer<diagnostics::to_text>::print_gap_in_line_numbering ()
 {
   gcc_assert (m_layout.m_options.show_line_numbers_p);
 
@@ -1943,7 +1948,7 @@ layout_printer<to_text>::print_gap_in_line_numbering ()
 
 template<>
 void
-layout_printer<to_html>::print_gap_in_line_numbering ()
+layout_printer<diagnostics::to_html>::print_gap_in_line_numbering ()
 {
   gcc_assert (m_layout.m_options.show_line_numbers_p);
 
@@ -2501,7 +2506,7 @@ layout_printer<Sink>::start_annotation_line (enum margin_kind margin)
 
 template<>
 void
-layout_printer<to_text>::end_line ()
+layout_printer<diagnostics::to_text>::end_line ()
 {
   m_sink.colorize_text_ensure_normal ();
   m_sink.add_newline ();
@@ -2512,7 +2517,7 @@ layout_printer<to_text>::end_line ()
 
 template<>
 void
-layout_printer<to_html>::end_line ()
+layout_printer<diagnostics::to_html>::end_line ()
 {
   m_sink.pop_html_tag ("td");
   m_sink.pop_html_tag ("tr");
@@ -2699,8 +2704,8 @@ public:
 
 template<>
 void
-layout_printer<to_text>::begin_label (int range_idx,
-                                     bool is_label_text)
+layout_printer<diagnostics::to_text>::begin_label (int range_idx,
+                                                  bool is_label_text)
 {
   /* Colorize the text, unless it's for labels for events in a
      diagnostic path.  */
@@ -2713,8 +2718,8 @@ layout_printer<to_text>::begin_label (int range_idx,
 
 template<>
 void
-layout_printer<to_html>::begin_label (int range_idx,
-                                     bool is_label_text)
+layout_printer<diagnostics::to_html>::begin_label (int range_idx,
+                                                  bool is_label_text)
 {
   if (is_label_text && m_sink.m_html_label_writer)
     m_sink.m_html_label_writer->begin_label ();
@@ -2726,15 +2731,15 @@ layout_printer<to_html>::begin_label (int range_idx,
 
 template<>
 void
-layout_printer<to_text>::end_label (int, bool)
+layout_printer<diagnostics::to_text>::end_label (int, bool)
 {
   m_sink.colorize_text_ensure_normal ();
 }
 
 template<>
 void
-layout_printer<to_html>::end_label (int range_idx,
-                                   bool is_label_text)
+layout_printer<diagnostics::to_html>::end_label (int range_idx,
+                                                bool is_label_text)
 {
   if (m_sink.get_highlight_color_for_range_idx (range_idx))
     m_sink.m_xp.pop_tag ("span");
@@ -3803,7 +3808,7 @@ layout_printer<Sink>::layout_printer (Sink &sink,
 
 bool
 gcc_rich_location::
-add_location_if_nearby (const diagnostic_source_print_policy &policy,
+add_location_if_nearby (const diagnostics::source_print_policy &policy,
                        location_t loc,
                        bool restrict_to_current_line_spans,
                        const range_label *label)
@@ -3827,27 +3832,28 @@ add_location_if_nearby (const diagnostic_source_print_policy &policy,
 
 bool
 gcc_rich_location::
-add_location_if_nearby (const diagnostic_context &dc,
+add_location_if_nearby (const diagnostics::context &dc,
                        location_t loc,
                        bool restrict_to_current_line_spans,
                        const range_label *label)
 {
-  diagnostic_source_print_policy source_policy (dc,
-                                               dc.m_source_printing);
+  diagnostics::source_print_policy source_policy (dc,
+                                                 dc.m_source_printing);
   return add_location_if_nearby (source_policy, loc,
                                 restrict_to_current_line_spans, label);
 }
 
+namespace diagnostics {
 
-/* As per diagnostic_source_print_policy::print, but don't print anything
+/* As per diagnostics::source_print_policy::print, but don't print anything
    if source printing is disabled, or if the location hasn't changed.  */
 
 void
-diagnostic_context::maybe_show_locus (const rich_location &richloc,
-                                     const diagnostic_source_printing_options &opts,
-                                     diagnostic_t diagnostic_kind,
-                                     pretty_printer &pp,
-                                     diagnostics::source_effect_info *effects)
+context::maybe_show_locus (const rich_location &richloc,
+                          const source_printing_options &opts,
+                          diagnostic_t diagnostic_kind,
+                          pretty_printer &pp,
+                          source_effect_info *effects)
 {
   const location_t loc = richloc.get_loc ();
   /* Do nothing if source-printing has been disabled.  */
@@ -3868,7 +3874,7 @@ diagnostic_context::maybe_show_locus (const rich_location &richloc,
 
   m_last_location = loc;
 
-  diagnostic_source_print_policy source_policy (*this, opts);
+  source_print_policy source_policy (*this, opts);
   source_policy.print (pp, richloc, diagnostic_kind, effects);
 }
 
@@ -3876,12 +3882,12 @@ diagnostic_context::maybe_show_locus (const rich_location &richloc,
    If non-null, use LABEL_WRITER when writing labelled ranges.  */
 
 void
-diagnostic_context::maybe_show_locus_as_html (const rich_location &richloc,
-                                             const diagnostic_source_printing_options &opts,
-                                             diagnostic_t diagnostic_kind,
-                                             xml::printer &xp,
-                                             diagnostics::source_effect_info *effects,
-                                             html_label_writer *label_writer)
+context::maybe_show_locus_as_html (const rich_location &richloc,
+                                  const source_printing_options &opts,
+                                  diagnostic_t diagnostic_kind,
+                                  xml::printer &xp,
+                                  source_effect_info *effects,
+                                  html_label_writer *label_writer)
 {
   const location_t loc = richloc.get_loc ();
   /* Do nothing if source-printing has been disabled.  */
@@ -3902,13 +3908,13 @@ diagnostic_context::maybe_show_locus_as_html (const rich_location &richloc,
 
   m_last_location = loc;
 
-  diagnostic_source_print_policy source_policy (*this, opts);
+  source_print_policy source_policy (*this, opts);
   source_policy.print_as_html (xp, richloc, diagnostic_kind, effects,
                               label_writer);
 }
 
-diagnostic_source_print_policy::
-diagnostic_source_print_policy (const diagnostic_context &dc)
+source_print_policy::
+source_print_policy (const context &dc)
 : m_options (dc.m_source_printing),
   m_location_policy (dc),
   m_text_start_span_cb (dc.m_text_callbacks.m_text_start_span),
@@ -3919,9 +3925,8 @@ diagnostic_source_print_policy (const diagnostic_context &dc)
 {
 }
 
-diagnostic_source_print_policy::
-diagnostic_source_print_policy (const diagnostic_context &dc,
-                               const diagnostic_source_printing_options &opts)
+source_print_policy::source_print_policy (const context &dc,
+                                         const source_printing_options &opts)
 : m_options (opts),
   m_location_policy (dc),
   m_text_start_span_cb (dc.m_text_callbacks.m_text_start_span),
@@ -3938,11 +3943,10 @@ diagnostic_source_print_policy (const diagnostic_context &dc,
    If EFFECTS is non-null, then use and update it.  */
 
 void
-diagnostic_source_print_policy::print (pretty_printer &pp,
-                                      const rich_location &richloc,
-                                      diagnostic_t diagnostic_kind,
-                                      diagnostics::source_effect_info *effects)
-  const
+source_print_policy::print (pretty_printer &pp,
+                           const rich_location &richloc,
+                           diagnostic_t diagnostic_kind,
+                           source_effect_info *effects) const
 {
   layout layout (*this, richloc, effects);
   colorizer col (pp, richloc, diagnostic_kind);
@@ -3956,12 +3960,11 @@ diagnostic_source_print_policy::print (pretty_printer &pp,
    If non-null, use LABEL_WRITER when writing labelled ranges.  */
 
 void
-diagnostic_source_print_policy::print_as_html (xml::printer &xp,
-                                              const rich_location &richloc,
-                                              diagnostic_t diagnostic_kind,
-                                              diagnostics::source_effect_info *effects,
-                                              html_label_writer *label_writer)
-  const
+source_print_policy::print_as_html (xml::printer &xp,
+                                   const rich_location &richloc,
+                                   diagnostic_t diagnostic_kind,
+                                   source_effect_info *effects,
+                                   html_label_writer *label_writer) const
 {
   layout layout (*this, richloc, effects);
   to_html sink (xp, &richloc, label_writer);
@@ -3971,9 +3974,12 @@ diagnostic_source_print_policy::print_as_html (xml::printer &xp,
   lp.print (*this);
 }
 
+} // namespace diagnostics
+
 template <typename Sink>
 void
-layout_printer<Sink>::print (const diagnostic_source_print_policy &source_policy)
+layout_printer<Sink>::
+print (const diagnostics::source_print_policy &source_policy)
 {
   typename Sink::auto_check_tag_nesting sentinel (m_sink);
 
@@ -4000,7 +4006,7 @@ layout_printer<Sink>::print (const diagnostic_source_print_policy &source_policy
            {
              expanded_location exploc
                = m_layout.get_expanded_location (line_span);
-             const diagnostic_location_print_policy &
+             const diagnostics::location_print_policy &
                loc_policy = source_policy.get_location_policy ();
              m_sink.invoke_start_span_fn (source_policy, loc_policy, exploc);
            }
@@ -4031,7 +4037,7 @@ namespace selftest {
 static std::unique_ptr<xml::node>
 make_element_for_locus (const rich_location &rich_loc,
                        diagnostic_t kind,
-                       diagnostic_context &dc)
+                       diagnostics::context &dc)
 {
   dc.m_last_location = UNKNOWN_LOCATION;
 
@@ -4052,7 +4058,7 @@ make_element_for_locus (const rich_location &rich_loc,
 static label_text
 make_raw_html_for_locus (const rich_location &rich_loc,
                         diagnostic_t kind,
-                        diagnostic_context &dc)
+                        diagnostics::context &dc)
 {
   auto node = make_element_for_locus (rich_loc, kind, dc);
   pretty_printer pp;
@@ -4078,10 +4084,10 @@ diagnostic_show_locus_fixture (const line_table_case &case_,
 /* Populate a char_display_policy based on DC and RICHLOC.  */
 
 static char_display_policy
-make_char_policy (const diagnostic_context &dc,
+make_char_policy (const diagnostics::context &dc,
                  const rich_location &richloc)
 {
-  diagnostic_source_print_policy source_policy (dc);
+  diagnostics::source_print_policy source_policy (dc);
   return ::make_char_policy (source_policy, richloc);
 }
 
@@ -4153,11 +4159,11 @@ test_offset_impl (int caret_byte_col, int max_width,
 {
   test_diagnostic_context dc;
   dc.m_source_printing.max_width = max_width;
-  /* diagnostic_context::min_margin_width sets the minimum space reserved for
+  /* min_margin_width sets the minimum space reserved for
      the line number plus one space after.  */
   dc.m_source_printing.min_margin_width = left_margin - test_linenum_sep + 1;
   dc.m_source_printing.show_line_numbers_p = true;
-  diagnostic_source_print_policy source_policy (dc);
+  diagnostics::source_print_policy source_policy (dc);
   rich_location richloc (line_table,
                         linemap_position_for_column (line_table,
                                                      caret_byte_col));
@@ -4273,15 +4279,15 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_)
       = test_left_margin - test_linenum_sep + 1;
     dc.m_source_printing.show_line_numbers_p = true;
     dc.m_source_printing.show_ruler_p = true;
-    diagnostic_source_print_policy policy (dc);
+    diagnostics::source_print_policy policy (dc);
     rich_location richloc (line_table,
                           linemap_position_for_column (line_table,
                                                        emoji_col));
     layout test_layout (policy, richloc, nullptr);
     colorizer col (*dc.get_reference_printer (),
                   richloc, DK_ERROR);
-    to_text sink (*dc.get_reference_printer (), col);
-    layout_printer<to_text> lp (sink, test_layout, false);
+    diagnostics::to_text sink (*dc.get_reference_printer (), col);
+    layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
     lp.print (policy);
     ASSERT_STREQ ("     |         1         \n"
                  "     |         1         \n"
@@ -4303,15 +4309,15 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_)
       = test_left_margin - test_linenum_sep + 1;
     dc.m_source_printing.show_line_numbers_p = true;
     dc.m_source_printing.show_ruler_p = true;
-    diagnostic_source_print_policy policy (dc);
+    diagnostics::source_print_policy policy (dc);
     rich_location richloc (line_table,
                           linemap_position_for_column (line_table,
                                                        emoji_col + 2));
     layout test_layout (dc, richloc, nullptr);
     colorizer col (*dc.get_reference_printer (),
                   richloc, DK_ERROR);
-    to_text sink (*dc.get_reference_printer (), col);
-    layout_printer<to_text> lp (sink, test_layout, false);
+    diagnostics::to_text sink (*dc.get_reference_printer (), col);
+    layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
     lp.print (policy);
     ASSERT_STREQ ("     |        1         1 \n"
                  "     |        1         2 \n"
@@ -4390,12 +4396,12 @@ test_layout_x_offset_display_tab (const line_table_case &case_)
     {
       test_diagnostic_context dc;
       dc.m_tabstop = tabstop;
-      diagnostic_source_print_policy policy (dc);
+      diagnostics::source_print_policy policy (dc);
       layout test_layout (policy, richloc, nullptr);
       colorizer col (*dc.get_reference_printer (),
                     richloc, DK_ERROR);
-      to_text sink (*dc.get_reference_printer (), col);
-      layout_printer<to_text> lp (sink, test_layout, false);
+      diagnostics::to_text sink (*dc.get_reference_printer (), col);
+      layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
       lp.print (policy);
       const char *out = pp_formatted_text (dc.get_reference_printer ());
       ASSERT_EQ (nullptr, strchr (out, '\t'));
@@ -4418,12 +4424,12 @@ test_layout_x_offset_display_tab (const line_table_case &case_)
       dc.m_source_printing.min_margin_width
        = test_left_margin - test_linenum_sep + 1;
       dc.m_source_printing.show_line_numbers_p = true;
-      diagnostic_source_print_policy policy (dc);
+      diagnostics::source_print_policy policy (dc);
       layout test_layout (policy, richloc, nullptr);
       colorizer col (*dc.get_reference_printer (),
                     richloc, DK_ERROR);
-      to_text sink (*dc.get_reference_printer (), col);
-      layout_printer<to_text> lp (sink, test_layout, false);
+      diagnostics::to_text sink (*dc.get_reference_printer (), col);
+      layout_printer<diagnostics::to_text> lp (sink, test_layout, false);
       lp.print (policy);
 
       /* We have arranged things so that two columns will be printed before
index e3206dfb70508ada912647f06e294bb94bd37285..aad7cdd4eeecf6bab6db5e8fe1f035ef8124ad37 100644 (file)
@@ -205,7 +205,7 @@ text_sink::on_report_diagnostic (const diagnostic_info &diagnostic,
 {
   pretty_printer *pp = get_printer ();
 
-  (*diagnostic_text_starter (&m_context)) (*this, &diagnostic);
+  (*text_starter (&m_context)) (*this, &diagnostic);
 
   pp_output_formatted_text (pp, m_context.get_urlifier ());
 
@@ -242,9 +242,9 @@ text_sink::on_report_diagnostic (const diagnostic_info &diagnostic,
        }
     }
 
-  (*diagnostic_text_finalizer (&m_context)) (*this,
-                                            &diagnostic,
-                                            orig_diag_kind);
+  (*text_finalizer (&m_context)) (*this,
+                                 &diagnostic,
+                                 orig_diag_kind);
 
   if (m_show_nesting && m_show_locations_in_nesting)
     get_context ().m_last_location = diagnostic_location (&diagnostic);
@@ -353,7 +353,7 @@ get_bullet_point_unichar (bool unicode)
 /* Return true if DC's theme supports unicode characters.  */
 
 static bool
-use_unicode_p (const diagnostic_context &dc)
+use_unicode_p (const context &dc)
 {
   if (text_art::theme *theme = dc.get_diagram_theme ())
     return theme->unicode_p ();
@@ -365,7 +365,7 @@ use_unicode_p (const diagnostic_context &dc)
    nested diagnostics.  */
 
 static unsigned
-get_bullet_point_unichar (diagnostic_context &dc)
+get_bullet_point_unichar (context &dc)
 {
   return get_bullet_point_unichar (use_unicode_p (dc));
 }
@@ -407,9 +407,9 @@ text_sink::build_indent_prefix (bool with_bullet) const
 
 void
 text_sink::append_note (location_t location,
-                                           const char * gmsgid, ...)
+                       const char * gmsgid, ...)
 {
-  diagnostic_context *context = &get_context ();
+  context *dc = &get_context ();
 
   diagnostic_info diagnostic;
   va_list ap;
@@ -417,7 +417,7 @@ text_sink::append_note (location_t location,
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_NOTE);
-  if (context->m_inhibit_notes_p)
+  if (dc->m_inhibit_notes_p)
     {
       va_end (ap);
       return;
@@ -430,7 +430,7 @@ text_sink::append_note (location_t location,
   pp_destroy_prefix (pp);
   pp_set_prefix (pp, saved_prefix);
   pp_newline (pp);
-  diagnostic_show_locus (context, get_source_printing_options (),
+  diagnostic_show_locus (dc, get_source_printing_options (),
                         &richloc, DK_NOTE, pp);
   va_end (ap);
 }
@@ -539,9 +539,8 @@ text_sink::print_any_rules (const diagnostic_info &diagnostic)
     }
 }
 
-/* Print any metadata about the option used to control DIAGNOSTIC to CONTEXT's
-   printer, e.g. " [-Werror=uninitialized]".
-   Subroutine of diagnostic_context::report_diagnostic.  */
+/* Print any metadata about the option used to control DIAGNOSTIC to
+   the context's printer, e.g. " [-Werror=uninitialized]".  */
 
 void
 text_sink::print_option_information (const diagnostic_info &diagnostic,
@@ -600,10 +599,10 @@ text_sink::includes_seen_p (const line_map_ordinary *map)
 label_text
 text_sink::get_location_text (const expanded_location &s) const
 {
-  diagnostic_column_policy column_policy (get_context ());
-  return column_policy.get_location_text (s,
-                                         show_column_p (),
-                                         pp_show_color (get_printer ()));
+  column_policy column_policy_ (get_context ());
+  return column_policy_.get_location_text (s,
+                                          show_column_p (),
+                                          pp_show_color (get_printer ()));
 }
 
 /* Helpers for writing lang-specific starters/finalizers for text output.  */
index e54a85d87cc75b065f72bacb4c6d4f876d400dac..f008cb33601d4f12d9209de36476c61fee09cdf4 100644 (file)
@@ -28,23 +28,23 @@ namespace diagnostics {
 /* Subclass of diagnostics::sink for classic text-based output
    to stderr.
 
-   Uses diagnostic_context.m_text_callbacks to provide client-specific
+   Uses diagnostics::context.m_text_callbacks to provide client-specific
    textual output (e.g. include paths, macro expansions, etc).  */
 
 class text_sink : public sink
 {
 public:
-  text_sink (diagnostic_context &context,
-            diagnostic_source_printing_options *source_printing = nullptr,
+  text_sink (context &dc,
+            source_printing_options *source_printing = nullptr,
             bool follows_reference_printer = false)
-  : sink (context),
+  : sink (dc),
     m_saved_output_buffer (nullptr),
-    m_column_policy (context),
+    m_column_policy (dc),
     m_last_module (nullptr),
     m_includes_seen (nullptr),
     m_source_printing (source_printing
                       ? *source_printing
-                      : context.m_source_printing),
+                      : dc.m_source_printing),
     m_follows_reference_printer (follows_reference_printer),
     m_show_nesting (false),
     m_show_nesting_levels (false)
@@ -93,11 +93,11 @@ public:
 
   bool show_column_p () const { return get_context ().m_show_column; }
 
-  const diagnostic_column_policy &get_column_policy () const
+  const column_policy &get_column_policy () const
   {
     return m_column_policy;
   }
-  diagnostic_location_print_policy get_location_print_policy () const;
+  location_print_policy get_location_print_policy () const;
 
   bool show_nesting_p () const { return m_show_nesting; }
   bool show_locations_in_nesting_p () const
@@ -117,11 +117,11 @@ public:
 
   label_text get_location_text (const expanded_location &s) const;
 
-  diagnostic_source_printing_options &get_source_printing_options ()
+  source_printing_options &get_source_printing_options ()
   {
     return m_source_printing;
   }
-  const diagnostic_source_printing_options &get_source_printing_options () const
+  const source_printing_options &get_source_printing_options () const
   {
     return m_source_printing;
   }
@@ -137,7 +137,7 @@ protected:
   /* For handling diagnostic_buffer.  */
   output_buffer *m_saved_output_buffer;
 
-  diagnostic_column_policy m_column_policy;
+  column_policy m_column_policy;
 
   /* Used to detect when the input file stack has changed since last
      described.  */
@@ -147,10 +147,10 @@ protected:
      include path for.  */
   hash_set<location_t, false, location_hash> *m_includes_seen;
 
-  diagnostic_source_printing_options &m_source_printing;
+  source_printing_options &m_source_printing;
 
   /* If true, this is the initial default text output format created
-     when the diagnostic_context was created, and, in particular, before
+     when the diagnostics::context was created, and, in particular, before
      initializations of color and m_url_format.  Hence this should follow
      the dc's reference printer for these.
      If false, this text output was created after the dc was created, and
index a088d761adffce39c1f4f3c06b0ddc8bd3b8102e..e7e50a96a8c0af2e77709104c809acaa69a0ccb4 100644 (file)
@@ -460,7 +460,7 @@ gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec,
 /* Return a malloc'd string describing the kind of diagnostic.  The
    caller is responsible for freeing the memory.  */
 static char *
-gfc_diagnostic_build_kind_prefix (diagnostic_context *context,
+gfc_diagnostic_build_kind_prefix (diagnostics::context *context,
                                  const diagnostic_info *diagnostic)
 {
   static const char *const diagnostic_kind_text[] = {
@@ -492,7 +492,7 @@ gfc_diagnostic_build_kind_prefix (diagnostic_context *context,
 /* Return a malloc'd string describing a location.  The caller is
    responsible for freeing the memory.  */
 static char *
-gfc_diagnostic_build_locus_prefix (const diagnostic_location_print_policy &loc_policy,
+gfc_diagnostic_build_locus_prefix (const diagnostics::location_print_policy &loc_policy,
                                   expanded_location s,
                                   bool colorize)
 {
@@ -511,7 +511,7 @@ gfc_diagnostic_build_locus_prefix (const diagnostic_location_print_policy &loc_p
 /* Return a malloc'd string describing two locations.  The caller is
    responsible for freeing the memory.  */
 static char *
-gfc_diagnostic_build_locus_prefix (const diagnostic_location_print_policy &loc_policy,
+gfc_diagnostic_build_locus_prefix (const diagnostics::location_print_policy &loc_policy,
                                   expanded_location s, expanded_location s2,
                                   bool colorize)
 {
@@ -551,7 +551,7 @@ static void
 gfc_diagnostic_text_starter (diagnostics::text_sink &text_output,
                             const diagnostic_info *diagnostic)
 {
-  diagnostic_context *const context = &text_output.get_context ();
+  diagnostics::context *const context = &text_output.get_context ();
   pretty_printer *const pp = text_output.get_printer ();
   char * kind_prefix = gfc_diagnostic_build_kind_prefix (context, diagnostic);
 
@@ -566,7 +566,7 @@ gfc_diagnostic_text_starter (diagnostics::text_sink &text_output,
       same_locus = diagnostic_same_line (context, s1, s2);
     }
 
-  diagnostic_location_print_policy loc_policy (text_output);
+  diagnostics::location_print_policy loc_policy (text_output);
   const bool colorize = pp_show_color (pp);
   char * locus_prefix = (one_locus || !same_locus)
     ? gfc_diagnostic_build_locus_prefix (loc_policy, s1, colorize)
@@ -617,11 +617,11 @@ gfc_diagnostic_text_starter (diagnostics::text_sink &text_output,
 }
 
 static void
-gfc_diagnostic_start_span (const diagnostic_location_print_policy &loc_policy,
-                          to_text &sink,
+gfc_diagnostic_start_span (const diagnostics::location_print_policy &loc_policy,
+                          diagnostics::to_text &sink,
                           expanded_location exploc)
 {
-  pretty_printer *pp = get_printer (sink);
+  pretty_printer *pp = diagnostics::get_printer (sink);
   const bool colorize = pp_show_color (pp);
   char *locus_prefix
     = gfc_diagnostic_build_locus_prefix (loc_policy, exploc, colorize);
@@ -950,9 +950,9 @@ gfc_errors_to_warnings (bool f)
 void
 gfc_diagnostics_init (void)
 {
-  diagnostic_text_starter (global_dc) = gfc_diagnostic_text_starter;
-  diagnostic_start_span (global_dc) = gfc_diagnostic_start_span;
-  diagnostic_text_finalizer (global_dc) = gfc_diagnostic_text_finalizer;
+  diagnostics::text_starter (global_dc) = gfc_diagnostic_text_starter;
+  diagnostics::start_span (global_dc) = gfc_diagnostic_start_span;
+  diagnostics::text_finalizer (global_dc) = gfc_diagnostic_text_finalizer;
   global_dc->set_format_decoder (gfc_format_decoder);
   global_dc->m_source_printing.caret_chars[0] = '1';
   global_dc->m_source_printing.caret_chars[1] = '2';
@@ -967,8 +967,8 @@ gfc_diagnostics_finish (void)
   tree_diagnostics_defaults (global_dc);
   /* We still want to use the gfc starter and finalizer, not the tree
      defaults.  */
-  diagnostic_text_starter (global_dc) = gfc_diagnostic_text_starter;
-  diagnostic_text_finalizer (global_dc) = gfc_diagnostic_text_finalizer;
+  diagnostics::text_starter (global_dc) = gfc_diagnostic_text_starter;
+  diagnostics::text_finalizer (global_dc) = gfc_diagnostic_text_finalizer;
   global_dc->m_source_printing.caret_chars[0] = '^';
   global_dc->m_source_printing.caret_chars[1] = '^';
   delete error_buffer;
index 1d85e7e434d1dda2a233c01cbb546b879c4f6cd8..69cf074a9ac55c4215fd25028a0f7acaa4ae8072 100644 (file)
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "rich-location.h"
 
-class diagnostic_source_print_policy;
+namespace diagnostics { class source_print_policy; }
 
 /* A gcc_rich_location is libcpp's rich_location with additional
    helper methods for working with gcc's types.  The class is not
@@ -81,12 +81,12 @@ class gcc_rich_location : public rich_location
 
      Implemented in diagnostics/source-printing.cc.  */
 
-  bool add_location_if_nearby (const diagnostic_source_print_policy &policy,
+  bool add_location_if_nearby (const diagnostics::source_print_policy &policy,
                               location_t loc,
                               bool restrict_to_current_line_spans = true,
                               const range_label *label = NULL);
 
-  bool add_location_if_nearby (const diagnostic_context &dc,
+  bool add_location_if_nearby (const diagnostics::context &dc,
                               location_t loc,
                               bool restrict_to_current_line_spans = true,
                               const range_label *label = NULL);
index 6227c32d782281ccecc4ec7b4b5c6276d94ce4bb..0899018fdb6d4e2504584a228066f2b5a05823f9 100644 (file)
@@ -4195,7 +4195,7 @@ driver_handle_option (struct gcc_options *opts,
                      unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
                      location_t loc,
                      const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
-                     diagnostic_context *dc,
+                     diagnostics::context *dc,
                      void (*) (void))
 {
   size_t opt_index = decoded->opt_index;
index 417571f04ac65d8c452f5e46334c74f0da4a81e6..1ee3d923f61807abb66f6d27da9f98c71e6c8db3 100644 (file)
@@ -293,12 +293,12 @@ See also 'help-gcc-hooks'.
 end
 
 define break-on-diagnostic
-break diagnostic_context::maybe_show_locus
+break diagnostics::context::maybe_show_locus
 end
 
 document break-on-diagnostic
-Put a breakpoint on diagnostic_show_locus, called whenever a diagnostic
-is emitted (as opposed to those warnings that are suppressed by
+Put a breakpoint on diagnostics::context::show_locus, called whenever
+a diagnostic is emitted (as opposed to those warnings that are suppressed by
 command-line options).
 end
 
index e6ad4cf91fbb9a0d30097a7f19cb9b6b3ce181d6..7fe65a1f3afa6ad3699e7d67a183691c3ce17d4f 100644 (file)
@@ -1000,7 +1000,7 @@ struct ggc_root_tab jit_root_tab[] =
 class jit_diagnostic_listener : public diagnostics::text_sink
 {
 public:
-  jit_diagnostic_listener (diagnostic_context &dc,
+  jit_diagnostic_listener (diagnostics::context &dc,
                           gcc::jit::playback::context &playback_ctxt)
   : diagnostics::text_sink (dc),
     m_playback_ctxt (playback_ctxt)
@@ -1081,8 +1081,8 @@ jit_langhook_init (void)
     }
 
   gcc_assert (global_dc);
-  diagnostic_text_starter (global_dc) = jit_begin_diagnostic;
-  diagnostic_text_finalizer (global_dc) = jit_end_diagnostic;
+  diagnostics::text_starter (global_dc) = jit_begin_diagnostic;
+  diagnostics::text_finalizer (global_dc) = jit_end_diagnostic;
   auto sink
     = std::make_unique<jit_diagnostic_listener>
        (*global_dc,
index 1d11502747b5324636288a6c2649f834484cb9d1..b0625dca71f114c5f89a8ad6baaa0c0783c90aa3 100644 (file)
@@ -30,8 +30,11 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "jit-recording.h"
 
-class diagnostic_context;
-namespace diagnostics { struct diagnostic_info; }
+namespace diagnostics
+{
+  class context;
+  struct diagnostic_info;
+}
 
 namespace gcc {
 
index c8a7a62648e775b90703448d4203f5d478d51b74..518509ae8f6307939f101e454a6dd36c05a14e87 100644 (file)
@@ -71,7 +71,7 @@ extern tree lhd_builtin_function (tree);
 extern tree lhd_enum_underlying_base_type (const_tree);
 
 /* Declarations of default tree inlining hooks.  */
-extern void lhd_initialize_diagnostics (diagnostic_context *);
+extern void lhd_initialize_diagnostics (diagnostics::context *);
 extern void lhd_init_options (unsigned int,
                              struct cl_decoded_option *);
 extern bool lhd_complain_wrong_lang_p (const struct cl_option *);
index 95ea94cce3498f63f871ab1b5dc3c139195af4c8..56c2c733c0c1e44b0f936a57cfc5daa2b0d5edf7 100644 (file)
@@ -330,7 +330,7 @@ global_decl_processing (void)
 
 /* Called to perform language-specific initialization of CTX.  */
 void
-lhd_initialize_diagnostics (diagnostic_context *ctx ATTRIBUTE_UNUSED)
+lhd_initialize_diagnostics (diagnostics::context *ctx ATTRIBUTE_UNUSED)
 {
 }
 
@@ -373,7 +373,7 @@ lhd_print_error_function (diagnostics::text_sink &text_output,
                          const char *file,
                          const diagnostic_info *diagnostic)
 {
-  diagnostic_context *const context = &text_output.get_context ();
+  diagnostics::context *const context = &text_output.get_context ();
   if (diagnostic_last_function_changed (context, diagnostic))
     {
       pretty_printer *const pp = text_output.get_printer ();
index 93df485d35f0959cccd8305edf30e61941936a81..3bf41522732136209cfca8251ee0a01bb31a8378 100644 (file)
@@ -421,7 +421,7 @@ struct lang_hooks
 
   /* Callback used to perform language-specific initialization for the
      global diagnostic context structure.  */
-  void (*initialize_diagnostics) (diagnostic_context *);
+  void (*initialize_diagnostics) (diagnostics::context *);
 
   /* Beginning the main source file.  */
   void (*preprocess_main_file) (cpp_reader *, line_maps *,
index a55151dd232ac68a4bac992e3e13867a2c8f5d11..389a11d5dea6253c5eba550718512112fdfc4528 100644 (file)
@@ -232,7 +232,7 @@ public:
                        FILE *dst_stream,
                        enum diagnostic_colorize colorize);
 
-  diagnostic_source_printing_options &get_source_printing_options ()
+  diagnostics::source_printing_options &get_source_printing_options ()
   {
     return m_source_printing;
   }
@@ -246,7 +246,7 @@ public:
 
 private:
   diagnostics::text_sink *m_inner_sink; // borrowed from dc
-  diagnostic_source_printing_options m_source_printing;
+  diagnostics::source_printing_options m_source_printing;
 };
 
 /* A token_printer that makes a deep copy of the pp_token_list
@@ -670,7 +670,7 @@ public:
     m_dc.set_client_data_hooks
       (std::make_unique<impl_diagnostic_client_data_hooks> (*this));
 
-    diagnostic_text_starter (&m_dc) = diagnostic_text_sink::text_starter;
+    diagnostics::text_starter (&m_dc) = diagnostic_text_sink::text_starter;
 
     m_edit_context
       = std::make_unique <diagnostics::edit_context> (m_dc.get_file_cache ());
@@ -694,7 +694,7 @@ public:
   }
 
   line_maps *get_line_table () { return &m_line_table; }
-  diagnostic_context &get_dc () { return m_dc; }
+  diagnostics::context &get_dc () { return m_dc; }
 
   const diagnostics::logical_locations::manager &
   get_logical_location_manager () const
@@ -893,7 +893,7 @@ private:
     return phys_loc;
   }
 
-  diagnostic_context m_dc;
+  diagnostics::context m_dc;
   line_maps m_line_table;
   impl_client_version_info m_client_version_info;
   std::vector<std::unique_ptr<sink>> m_sinks;
@@ -1963,7 +1963,7 @@ diagnostic_manager_debug_dump_location (const diagnostic_manager *diag_mgr,
       diag_mgr->set_line_table_global ();
       const expanded_location exp_loc (expand_location (cpplib_loc));
 
-      diagnostic_context dc;
+      diagnostics::context dc;
       diagnostic_initialize (&dc, 0);
       dc.m_show_column = true;
 
index 3d074e4d6fe0a0a210feb157a49062a825ca5dff..4e9b53862200b8b31435da4909e5e12c4e355946 100644 (file)
@@ -497,7 +497,7 @@ print "                           const struct cl_decoded_option *decoded,   "
 print "                           unsigned int lang_mask, int kind,          "
 print "                           location_t loc,                            "
 print "                           const struct cl_option_handlers *handlers, "
-print "                           diagnostic_context *dc)                    "
+print "                           diagnostics::context *dc)                  "
 print "{                                                                     "
 print "  size_t scode = decoded->opt_index;                                  "
 print "  HOST_WIDE_INT value = decoded->value;                               "
@@ -554,7 +554,7 @@ for (i = 0; i < n_langs; i++) {
     print "                           unsigned int lang_mask" mark_unused ", int kind" mark_unused ",          "
     print "                           location_t loc" mark_unused ",                            "
     print "                           const struct cl_option_handlers *handlers" mark_unused ", "
-    print "                           diagnostic_context *dc" mark_unused ")                    "
+    print "                           diagnostics::context *dc" mark_unused ")                  "
     print "{                                                                     "
     print "  enum opt_code code = (enum opt_code) scode;                         "
     print "                                                                      "
index b6613d348ebe3f8f2971e1224aea015bc1e9c74e..91fcf569463546df0a149877f1efed6b35ba8e65 100644 (file)
@@ -357,7 +357,7 @@ print "                           const struct cl_decoded_option *decoded,   "
 print "                           unsigned int lang_mask, int kind,          "
 print "                           location_t loc,                            "
 print "                           const struct cl_option_handlers *handlers, "
-print "                           diagnostic_context *dc);                   "
+print "                           diagnostics::context *dc);                   "
 for (i = 0; i < n_langs; i++) {
     lang_name = lang_sanitized_name(langs[i]);
     print "bool"
@@ -368,7 +368,7 @@ for (i = 0; i < n_langs; i++) {
     print "                           unsigned int lang_mask, int kind,"
     print "                           location_t loc,"
     print "                           const struct cl_option_handlers *handlers,"
-    print "                           diagnostic_context *dc);"
+    print "                           diagnostics::context *dc);"
 }
 print "void cpp_handle_option_auto (const struct gcc_options * opts, size_t scode,"
 print "                             struct cpp_options * cpp_opts);"
index 03b1a79c1c094937d945209252d498aae362dd22..16486e7111cf3c9cfd80f531596d9b884fcee927 100644 (file)
@@ -1298,7 +1298,7 @@ handle_option (struct gcc_options *opts,
               const struct cl_decoded_option *decoded,
               unsigned int lang_mask, int kind, location_t loc,
               const struct cl_option_handlers *handlers,
-              bool generated_p, diagnostic_context *dc)
+              bool generated_p, diagnostics::context *dc)
 {
   size_t opt_index = decoded->opt_index;
   const char *arg = decoded->arg;
@@ -1336,7 +1336,7 @@ handle_generated_option (struct gcc_options *opts,
                         size_t opt_index, const char *arg, HOST_WIDE_INT value,
                         unsigned int lang_mask, int kind, location_t loc,
                         const struct cl_option_handlers *handlers,
-                        bool generated_p, diagnostic_context *dc)
+                        bool generated_p, diagnostics::context *dc)
 {
   struct cl_decoded_option decoded;
 
@@ -1604,7 +1604,7 @@ read_cmdline_option (struct gcc_options *opts,
                     location_t loc,
                     unsigned int lang_mask,
                     const struct cl_option_handlers *handlers,
-                    diagnostic_context *dc)
+                    diagnostics::context *dc)
 {
   const struct cl_option *option;
   const char *opt = decoded->orig_option_with_args_text;
@@ -1658,7 +1658,7 @@ read_cmdline_option (struct gcc_options *opts,
 void
 set_option (struct gcc_options *opts, struct gcc_options *opts_set,
            size_t opt_index, HOST_WIDE_INT value, const char *arg,
-           int kind, location_t loc, diagnostic_context *dc,
+           int kind, location_t loc, diagnostics::context *dc,
            HOST_WIDE_INT mask /* = 0 */)
 {
   const struct cl_option *option = &cl_options[opt_index];
@@ -1941,7 +1941,7 @@ control_warning_option (unsigned int opt_index, int kind, const char *arg,
                        const struct cl_option_handlers *handlers,
                        struct gcc_options *opts,
                        struct gcc_options *opts_set,
-                       diagnostic_context *dc)
+                       diagnostics::context *dc)
 {
   if (cl_options[opt_index].alias_target != N_OPTS)
     {
index 0c4b5e182ab3f9e03007353669171fe5ee4b8d13..70d7d74af61154e945af892bc737dd242919467e 100644 (file)
@@ -43,7 +43,7 @@ struct opt_spec_context : public diagnostics::output_spec::dc_spec_context
 {
 public:
   opt_spec_context (const gcc_options &opts,
-                   diagnostic_context &dc,
+                   diagnostics::context &dc,
                    line_maps *location_mgr,
                    location_t loc,
                    const char *option_name)
@@ -70,7 +70,7 @@ public:
 
 void
 handle_OPT_fdiagnostics_add_output_ (const gcc_options &opts,
-                                    diagnostic_context &dc,
+                                    diagnostics::context &dc,
                                     const char *arg,
                                     location_t loc)
 {
@@ -89,7 +89,7 @@ handle_OPT_fdiagnostics_add_output_ (const gcc_options &opts,
 
 void
 handle_OPT_fdiagnostics_set_output_ (const gcc_options &opts,
-                                    diagnostic_context &dc,
+                                    diagnostics::context &dc,
                                     const char *arg,
                                     location_t loc)
 {
index 384fbb31b5bf7ed823a19e7d9742b3823abfb134..9b799e4b788adadebebcff47b50f0888907e0abd 100644 (file)
@@ -20,9 +20,9 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_OPTS_DIAGNOSTIC_H
 #define GCC_OPTS_DIAGNOSTIC_H
 
-/* Abstract subclass of diagnostic_option_manager for gcc options.  */
+/* Abstract subclass of diagnostics::option_manager for gcc options.  */
 
-class gcc_diagnostic_option_manager : public diagnostic_option_manager
+class gcc_diagnostic_option_manager : public diagnostics::option_manager
 {
 public:
   char *make_option_url (diagnostic_option_id option_id) const final override;
@@ -40,7 +40,7 @@ protected:
 class compiler_diagnostic_option_manager : public gcc_diagnostic_option_manager
 {
 public:
-  compiler_diagnostic_option_manager (const diagnostic_context &context,
+  compiler_diagnostic_option_manager (const diagnostics::context &context,
                                      unsigned lang_mask,
                                      void *opts)
   : gcc_diagnostic_option_manager (lang_mask),
@@ -55,19 +55,19 @@ public:
                          diagnostic_t diag_kind) const final override;
 
 private:
-  const diagnostic_context &m_context;
+  const diagnostics::context &m_context;
   void *m_opts;
 };
 
 extern void
 handle_OPT_fdiagnostics_add_output_ (const gcc_options &opts,
-                                    diagnostic_context &dc,
+                                    diagnostics::context &dc,
                                     const char *arg,
                                     location_t loc);
 
 extern void
 handle_OPT_fdiagnostics_set_output_ (const gcc_options &opts,
-                                    diagnostic_context &dc,
+                                    diagnostics::context &dc,
                                     const char *arg,
                                     location_t loc);
 #endif
index b9b42d3b23338bf65905745aa34d0ca926fe4e8a..701a6bb1599cf573b88cee6890577daaf16b08e2 100644 (file)
@@ -181,7 +181,7 @@ lang_handle_option (struct gcc_options *opts,
                    unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
                    location_t loc,
                    const struct cl_option_handlers *handlers,
-                   diagnostic_context *dc,
+                   diagnostics::context *dc,
                    void (*) (void))
 {
   gcc_assert (opts == &global_options);
@@ -215,7 +215,7 @@ read_cmdline_options (struct gcc_options *opts, struct gcc_options *opts_set,
                      location_t loc,
                      unsigned int lang_mask,
                      const struct cl_option_handlers *handlers,
-                     diagnostic_context *dc)
+                     diagnostics::context *dc)
 {
   unsigned int i;
 
@@ -312,7 +312,7 @@ void
 decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
                struct cl_decoded_option *decoded_options,
                unsigned int decoded_options_count,
-               location_t loc, diagnostic_context *dc,
+               location_t loc, diagnostics::context *dc,
                void (*target_option_override_hook) (void))
 {
   struct cl_option_handlers handlers;
index 341f0e3284bb98d5efb163414b40c44f184ffcc3..57f9f1949180662af0d111a95464f1fe7c3ccea4 100644 (file)
@@ -347,7 +347,7 @@ static void set_debug_level (uint32_t dinfo, int extended,
                             location_t loc);
 static void set_fast_math_flags (struct gcc_options *opts, int set);
 static void decode_d_option (const char *arg, struct gcc_options *opts,
-                            location_t loc, diagnostic_context *dc);
+                            location_t loc, diagnostics::context *dc);
 static void set_unsafe_math_optimizations_flags (struct gcc_options *opts,
                                                 int set);
 static void enable_warning_as_error (const char *arg, int value,
@@ -356,7 +356,7 @@ static void enable_warning_as_error (const char *arg, int value,
                                     struct gcc_options *opts,
                                     struct gcc_options *opts_set,
                                     location_t loc,
-                                    diagnostic_context *dc);
+                                    diagnostics::context *dc);
 
 /* Handle a back-end option; arguments and return value as for
    handle_option.  */
@@ -368,7 +368,7 @@ target_handle_option (struct gcc_options *opts,
                      unsigned int lang_mask ATTRIBUTE_UNUSED, int kind,
                      location_t loc,
                      const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED,
-                     diagnostic_context *dc, void (*) (void))
+                     diagnostics::context *dc, void (*) (void))
 {
   gcc_assert (dc == global_dc);
   gcc_assert (kind == DK_UNSPECIFIED);
@@ -469,7 +469,7 @@ maybe_default_option (struct gcc_options *opts,
                      unsigned int lang_mask,
                      const struct cl_option_handlers *handlers,
                      location_t loc,
-                     diagnostic_context *dc)
+                     diagnostics::context *dc)
 {
   const struct cl_option *option = &cl_options[default_opt->opt_index];
   bool enabled;
@@ -559,7 +559,7 @@ maybe_default_options (struct gcc_options *opts,
                       unsigned int lang_mask,
                       const struct cl_option_handlers *handlers,
                       location_t loc,
-                      diagnostic_context *dc)
+                      diagnostics::context *dc)
 {
   size_t i;
 
@@ -727,7 +727,7 @@ default_options_optimization (struct gcc_options *opts,
                              location_t loc,
                              unsigned int lang_mask,
                              const struct cl_option_handlers *handlers,
-                             diagnostic_context *dc)
+                             diagnostics::context *dc)
 {
   unsigned int i;
   int opt2;
@@ -2703,7 +2703,7 @@ common_handle_option (struct gcc_options *opts,
                      unsigned int lang_mask, int kind ATTRIBUTE_UNUSED,
                      location_t loc,
                      const struct cl_option_handlers *handlers,
-                     diagnostic_context *dc,
+                     diagnostics::context *dc,
                      void (*target_option_override_hook) (void))
 {
   size_t scode = decoded->opt_index;
@@ -3618,7 +3618,7 @@ set_debug_level (uint32_t dinfo, int extended, const char *arg,
    abort ().)  */
 
 static void
-setup_core_dumping (diagnostic_context *dc)
+setup_core_dumping (diagnostics::context *dc)
 {
 #ifdef SIGABRT
   signal (SIGABRT, SIG_DFL);
@@ -3642,7 +3642,7 @@ setup_core_dumping (diagnostic_context *dc)
 
 static void
 decode_d_option (const char *arg, struct gcc_options *opts,
-                location_t loc, diagnostic_context *dc)
+                location_t loc, diagnostics::context *dc)
 {
   int c;
 
@@ -3691,7 +3691,7 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
                         const struct cl_option_handlers *handlers,
                         struct gcc_options *opts,
                         struct gcc_options *opts_set,
-                        location_t loc, diagnostic_context *dc)
+                        location_t loc, diagnostics::context *dc)
 {
   char *new_option;
   int option_index;
index 382faab92506b11afc1cdf8dc57551ff28effa5a..ea92c4922a3b40366487dc01d1746d83db0a7d7f 100644 (file)
@@ -313,7 +313,7 @@ struct cl_option_handler_func
                   const struct cl_decoded_option *decoded,
                   unsigned int lang_mask, int kind, location_t loc,
                   const struct cl_option_handlers *handlers,
-                  diagnostic_context *dc,
+                  diagnostics::context *dc,
                   void (*target_option_override_hook) (void));
 
   /* The mask that must have some bit in common with the flags for the
@@ -390,7 +390,7 @@ extern void decode_options (struct gcc_options *opts,
                            struct cl_decoded_option *decoded_options,
                            unsigned int decoded_options_count,
                            location_t loc,
-                           diagnostic_context *dc,
+                           diagnostics::context *dc,
                            void (*target_option_override_hook) (void));
 extern int option_enabled (int opt_idx, unsigned lang_mask, void *opts);
 
@@ -399,7 +399,7 @@ extern bool get_option_state (struct gcc_options *, int,
 extern void set_option (struct gcc_options *opts,
                        struct gcc_options *opts_set,
                        size_t opt_index, HOST_WIDE_INT value, const char *arg,
-                       int kind, location_t loc, diagnostic_context *dc,
+                       int kind, location_t loc, diagnostics::context *dc,
                        HOST_WIDE_INT = 0);
 extern void *option_flag_var (int opt_index, struct gcc_options *opts);
 bool handle_generated_option (struct gcc_options *opts,
@@ -408,7 +408,7 @@ bool handle_generated_option (struct gcc_options *opts,
                              HOST_WIDE_INT value,
                              unsigned int lang_mask, int kind, location_t loc,
                              const struct cl_option_handlers *handlers,
-                             bool generated_p, diagnostic_context *dc);
+                             bool generated_p, diagnostics::context *dc);
 void generate_option (size_t opt_index, const char *arg, HOST_WIDE_INT value,
                      unsigned int lang_mask,
                      struct cl_decoded_option *decoded);
@@ -420,14 +420,14 @@ extern void read_cmdline_option (struct gcc_options *opts,
                                 location_t loc,
                                 unsigned int lang_mask,
                                 const struct cl_option_handlers *handlers,
-                                diagnostic_context *dc);
+                                diagnostics::context *dc);
 extern void control_warning_option (unsigned int opt_index, int kind,
                                    const char *arg, bool imply, location_t loc,
                                    unsigned int lang_mask,
                                    const struct cl_option_handlers *handlers,
                                    struct gcc_options *opts,
                                    struct gcc_options *opts_set,
-                                   diagnostic_context *dc);
+                                   diagnostics::context *dc);
 extern char *write_langs (unsigned int mask);
 extern void print_ignored_options (void);
 extern void handle_common_deferred_options (void);
@@ -442,7 +442,7 @@ extern bool common_handle_option (struct gcc_options *opts,
                                  unsigned int lang_mask, int kind,
                                  location_t loc,
                                  const struct cl_option_handlers *handlers,
-                                 diagnostic_context *dc,
+                                 diagnostics::context *dc,
                                  void (*target_option_override_hook) (void));
 extern bool target_handle_option (struct gcc_options *opts,
                                  struct gcc_options *opts_set,
@@ -450,7 +450,7 @@ extern bool target_handle_option (struct gcc_options *opts,
                                  unsigned int lang_mask, int kind,
                                  location_t loc,
                                  const struct cl_option_handlers *handlers,
-                                 diagnostic_context *dc,
+                                 diagnostics::context *dc,
                                  void (*target_option_override_hook) (void));
 extern void finish_options (struct gcc_options *opts,
                            struct gcc_options *opts_set,
@@ -466,7 +466,7 @@ extern void default_options_optimization (struct gcc_options *opts,
                                          location_t loc,
                                          unsigned int lang_mask,
                                          const struct cl_option_handlers *handlers,
-                                         diagnostic_context *dc);
+                                         diagnostics::context *dc);
 extern void set_struct_debug_option (struct gcc_options *opts,
                                     location_t loc,
                                     const char *value);
index 6242235a1bb1bb2a92e67972435f73ccef72f4c8..6f6f2bf0bfd9ca514a1e9d04fda2f4305f627625 100644 (file)
@@ -129,7 +129,7 @@ ResolveExpr::visit (AST::IdentifierExpr &expr)
         resolve.  Emit a funny ICE.  We set the finalizer to our custom one,
         and use the lower-level emit_diagnostic () instead of the more common
         internal_error_no_backtrace () in order to pass our locus.  */
-      diagnostic_text_finalizer (global_dc) = funny_ice_text_finalizer;
+      diagnostics::text_finalizer (global_dc) = funny_ice_text_finalizer;
       emit_diagnostic (DK_ICE_NOBT, expr.get_locus (), -1,
                       "are you trying to break %s? how dare you?",
                       expr.as_string ().c_str ());
index 6ec04229c8e75057d4b89598ac2777b51316d74a..fe9dea8fa62b62f87574cf975a8675d3de61ed8a 100644 (file)
@@ -375,7 +375,7 @@ Late::visit (AST::IdentifierExpr &expr)
     }
   else if (funny_error)
     {
-      diagnostic_text_finalizer (global_dc) = Resolver::funny_ice_text_finalizer;
+      diagnostics::text_finalizer (global_dc) = Resolver::funny_ice_text_finalizer;
       emit_diagnostic (DK_ICE_NOBT, expr.get_locus (), -1,
                       "are you trying to break %s? how dare you?",
                       expr.as_string ().c_str ());
index 2f16d0a3fc812eae2b7daabb352a5f16b45ec40d..321949852384fa006296f8c7858d9fbbdb18b54b 100644 (file)
@@ -41,7 +41,7 @@ test_diagnostic_context::test_diagnostic_context ()
   m_source_printing.enabled = true;
   m_source_printing.show_labels_p = true;
   m_show_column = true;
-  diagnostic_start_span (this) = start_span_cb;
+  diagnostics::start_span (this) = start_span_cb;
   m_source_printing.min_margin_width = 6;
   m_source_printing.max_width = 80;
   pp_buffer (get_sink (0).get_printer ())->m_flush_p = false;
@@ -57,12 +57,13 @@ test_diagnostic_context::~test_diagnostic_context ()
 
 void
 test_diagnostic_context::
-start_span_cb (const diagnostic_location_print_policy &loc_policy,
-              to_text &sink,
+start_span_cb (const diagnostics::location_print_policy &loc_policy,
+              diagnostics::to_text &sink,
               expanded_location exploc)
 {
   exploc.file = "FILENAME";
-  diagnostics::default_start_span_fn<to_text> (loc_policy, sink, exploc);
+  diagnostics::default_start_span_fn<diagnostics::to_text>
+    (loc_policy, sink, exploc);
 }
 
 bool
@@ -89,7 +90,7 @@ test_diagnostic_context::test_show_locus (rich_location &richloc)
 {
   pretty_printer *pp = get_reference_printer ();
   gcc_assert (pp);
-  diagnostic_source_print_policy source_policy (*this);
+  diagnostics::source_print_policy source_policy (*this);
   source_policy.print (*pp, richloc, DK_ERROR, nullptr);
   return pp_formatted_text (pp);
 }
index 53a78f87f02305e91be57ea2151296fba12fc211..6a5216650f92314403d7eb1efe13e89ec4969fcb 100644 (file)
@@ -27,10 +27,10 @@ along with GCC; see the file COPYING3.  If not see
 
 namespace selftest {
 
-/* Convenience subclass of diagnostic_context for testing
+/* Convenience subclass of diagnostics::context for testing
    the diagnostic subsystem.  */
 
-class test_diagnostic_context : public diagnostic_context
+class test_diagnostic_context : public diagnostics::context
 {
  public:
   test_diagnostic_context ();
@@ -39,8 +39,8 @@ class test_diagnostic_context : public diagnostic_context
   /* Implementation of diagnostic_start_span_fn, hiding the
      real filename (to avoid printing the names of tempfiles).  */
   static void
-  start_span_cb (const diagnostic_location_print_policy &,
-                to_text &sink,
+  start_span_cb (const diagnostics::location_print_policy &,
+                diagnostics::to_text &sink,
                 expanded_location exploc);
 
   /* Report a diagnostic to this context.  For a selftest, this
index 6151b6ebe79fc07e5c051d8c08005bcb7d9ef5f5..289af332acfe850fd68590d1eb7206c115fd9665 100644 (file)
@@ -21,7 +21,7 @@
 int plugin_is_GPL_compatible;
 
 void
-noop_text_starter_fn (diagnostic_text_output_format &, const diagnostic_info *)
+noop_text_starter_fn (diagnostics::text_sink &, const diagnostic_info *)
 {
 }
 
@@ -32,7 +32,7 @@ plugin_init (struct plugin_name_args *plugin_info,
   if (!plugin_default_version_check (version, &gcc_version))
     return 1;
 
-  diagnostic_text_starter (global_dc) = noop_text_starter_fn;
+  diagnostics::text_starter (global_dc) = noop_text_starter_fn;
 
   return 0;
 }
index d1bdb09fd2efe783947f9f57356414a7ab98a574..8d44c03986ccfb23a9a08166bf6de236f9029eb3 100644 (file)
@@ -175,11 +175,11 @@ test_diagnostic_text_starter (diagnostics::text_sink &text_output,
    expected output.  */
 
 void
-test_diagnostic_start_span_fn (const diagnostic_location_print_policy &,
-                              to_text &sink,
+test_diagnostic_start_span_fn (const diagnostics::location_print_policy &,
+                              diagnostics::to_text &sink,
                               expanded_location)
 {
-  pretty_printer *pp = get_printer (sink);
+  pretty_printer *pp = diagnostics::get_printer (sink);
   pp_string (pp, "START_SPAN_FN: ");
   pp_newline (pp);
 }
@@ -189,7 +189,7 @@ test_diagnostic_start_span_fn (const diagnostic_location_print_policy &,
 class custom_test_sink : public diagnostics::text_sink
 {
  public:
-  custom_test_sink (diagnostic_context &context)
+  custom_test_sink (diagnostics::context &context)
   : diagnostics::text_sink (context)
   {}
 
@@ -228,8 +228,8 @@ plugin_init (struct plugin_name_args *plugin_info,
   if (!plugin_default_version_check (version, &gcc_version))
     return 1;
 
-  diagnostic_text_starter (global_dc) = test_diagnostic_text_starter;
-  diagnostic_start_span (global_dc) = test_diagnostic_start_span_fn;
+  diagnostics::text_starter (global_dc) = test_diagnostic_text_starter;
+  diagnostics::start_span (global_dc) = test_diagnostic_start_span_fn;
   global_dc->set_sink (::std::make_unique<custom_test_sink> (*global_dc));
 
   pass_info.pass = new pass_test_groups (g);
index d22e73a730a9f1c81121df76b957391567d988a3..0342ccc2c4ba71e6315b827fabbe47b411742973 100644 (file)
@@ -176,7 +176,7 @@ test_show_locus (function *fun)
   location_t fnstart = fun->function_start_locus;
   int fnstart_line = LOCATION_LINE (fnstart);
 
-  diagnostic_text_finalizer (global_dc) = custom_diagnostic_text_finalizer;
+  diagnostics::text_finalizer (global_dc) = custom_diagnostic_text_finalizer;
 
   /* Hardcode the "terminal width", to verify the behavior of
      very wide lines.  */
index 89d6590512da7aff3afb396b8766732bd578527a..d45a33d168feeb7822664c43a0fa9a40fbd3a678 100644 (file)
@@ -39,7 +39,7 @@ on_pragma_registration (void */*gcc_data*/, void */*user_data*/)
 /* We add some extra testing during diagnostics by chaining up
    to the text finalizer.  */
 
-static diagnostic_text_finalizer_fn original_text_finalizer = NULL;
+static diagnostics::text_finalizer_fn original_text_finalizer = NULL;
 
 static void
 verify_unpacked_ranges  (diagnostics::text_sink &text_output,
@@ -104,15 +104,15 @@ plugin_init (struct plugin_name_args *plugin_info,
                     NULL); /* void *user_data */
 
   /* Hack in additional testing, based on the exact value supplied.  */
-  original_text_finalizer = diagnostic_text_finalizer (global_dc);
+  original_text_finalizer = diagnostics::text_finalizer (global_dc);
   switch (base_location)
     {
     case LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES + 1:
-      diagnostic_text_finalizer (global_dc) = verify_unpacked_ranges;
+      diagnostics::text_finalizer (global_dc) = verify_unpacked_ranges;
       break;
 
     case LINE_MAP_MAX_LOCATION_WITH_COLS + 1:
-      diagnostic_text_finalizer (global_dc) = verify_no_columns;
+      diagnostics::text_finalizer (global_dc) = verify_no_columns;
       break;
 
     default:
index 1ce61f140d3ac54b5449490b5d7691f51fa32faa..b7300b8dbf9f915116e843be38793cdc50c561a1 100644 (file)
@@ -1017,7 +1017,7 @@ open_auxiliary_file (const char *ext)
 /* Alternative diagnostics callback for reentered ICE reporting.  */
 
 static void
-internal_error_reentered (diagnostic_context *, const char *, va_list *)
+internal_error_reentered (diagnostics::context *, const char *, va_list *)
 {
   /* Flush the dump file if emergency_dump_function itself caused an ICE.  */
   if (dump_file)
@@ -1027,7 +1027,7 @@ internal_error_reentered (diagnostic_context *, const char *, va_list *)
 /* Auxiliary callback for the diagnostics code.  */
 
 static void
-internal_error_function (diagnostic_context *, const char *, va_list *)
+internal_error_function (diagnostics::context *, const char *, va_list *)
 {
   global_dc->set_internal_error_callback (internal_error_reentered);
   warn_if_plugins ();
index 84fbb7921f56b6ded2a65612aa7334e7245a47de..77eb292f787db3c2be11419dffb1647e3e73d74d 100644 (file)
@@ -32,7 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "plugin.h"
 #include "timevar.h"
 
-/* Concrete class for supplying a diagnostic_context with information
+/* Concrete class for supplying a diagnostics::context with information
    about a specific plugin within the client, when the client is the
    compiler (i.e. a GCC plugin).  */
 
index b2435df46b3276176fd31e9c1936539dd53dcbff..4e43842732d4eff206d5d38799f01b4b9067ce3a 100644 (file)
@@ -110,7 +110,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
    to the DIAGNOSTIC location.  */
 
 static void
-set_inlining_locations (diagnostic_context *,
+set_inlining_locations (diagnostics::context *,
                        diagnostic_info *diagnostic)
 {
   location_t loc = diagnostic_location (diagnostic);
@@ -175,10 +175,10 @@ set_inlining_locations (diagnostic_context *,
 
 /* Sets CONTEXT to use language independent diagnostics.  */
 void
-tree_diagnostics_defaults (diagnostic_context *context)
+tree_diagnostics_defaults (diagnostics::context *context)
 {
-  diagnostic_text_starter (context) = default_tree_diagnostic_text_starter;
-  diagnostic_text_finalizer (context) = diagnostics::default_text_finalizer;
+  diagnostics::text_starter (context) = default_tree_diagnostic_text_starter;
+  diagnostics::text_finalizer (context) = diagnostics::default_text_finalizer;
   context->set_format_decoder (default_tree_printer);
   context->set_set_locations_callback (set_inlining_locations);
   context->set_client_data_hooks (make_compiler_data_hooks ());
index b138b8b4ca9581c53ff3d79b1e0b4846e1316110..ffb0c2bab4f4f1898a0430b388460ade29cd1250 100644 (file)
@@ -48,10 +48,10 @@ along with GCC; see the file COPYING3.  If not see
        ? diagnostic_abstract_origin (DI)               \
        : current_function_decl)
 
-void diagnostic_report_current_function (diagnostic_context *,
+void diagnostic_report_current_function (diagnostics::context *,
                                         const diagnostic_info *);
 
-void tree_diagnostics_defaults (diagnostic_context *context);
+void tree_diagnostics_defaults (diagnostics::context *);
 bool default_tree_printer (pretty_printer *, text_info *, const char *,
                           int, bool, bool, bool, bool *, pp_token_list &);