GCC Middle and Back End API Reference
diagnostics Namespace Reference

Namespaces

namespace  changes
namespace  digraphs
namespace  dumping
namespace  logging
namespace  logical_locations
namespace  output_spec
namespace  paths
namespace  state_graphs

Data Structures

struct  bt_closure
class  buffer
class  char_span
class  client_data_hooks
class  client_plugin_info
class  client_version_info
struct  column_options
class  column_policy
class  content_renderer
class  context
struct  counters
struct  diagnostic_info
class  diagram
class  file_cache
class  file_cache_slot
class  html_builder
struct  html_doctypedecl
class  html_file_sink
struct  html_generation_options
class  html_label_writer
class  html_path_label_writer
class  html_sink
class  html_sink_buffer
class  html_token_printer
class  label_effects
struct  loc_map_pair
class  location_print_policy
class  option_classifier
struct  option_id
class  option_id_manager
class  output_file
class  per_sink_buffer
class  sarif_array_of_unique
class  sarif_artifact
class  sarif_artifact_change
class  sarif_artifact_content
class  sarif_artifact_location
class  sarif_builder
class  sarif_code_flow
class  sarif_edge
class  sarif_file_sink
class  sarif_fix
struct  sarif_generation_options
class  sarif_graph
class  sarif_ice_notification
class  sarif_invocation
class  sarif_location
class  sarif_location_manager
class  sarif_location_relationship
class  sarif_log
class  sarif_logical_location
class  sarif_message
class  sarif_multiformat_message_string
class  sarif_node
class  sarif_object
class  sarif_physical_location
class  sarif_property_bag
class  sarif_region
class  sarif_replacement
class  sarif_reporting_descriptor
class  sarif_reporting_descriptor_reference
class  sarif_result
class  sarif_run
class  sarif_serialization_format
class  sarif_serialization_format_json
class  sarif_sink
class  sarif_sink_buffer
class  sarif_stream_sink
class  sarif_thread_flow
class  sarif_thread_flow_location
class  sarif_tool
class  sarif_tool_component
class  sarif_tool_component_reference
class  sink
class  source_effect_info
class  source_print_policy
struct  source_printing_options
class  text_sink
class  text_sink_buffer
struct  to_html
struct  to_text

Typedefs

typedef void(* text_starter_fn) (text_sink &, const diagnostic_info *)
template<typename TextOrHtml>
using start_span_fn
typedef void(* text_finalizer_fn) (text_sink &, const diagnostic_info *, enum kind)

Enumerations

enum class  kind { last_diagnostic_kind , pop , any }
enum class  location_relationship_kind { includes , is_included_by , relevant , NUM_KINDS }
enum class  diagnostic_artifact_role {
  analysis_target , debug_output_file , result_file , scanned_file ,
  traced_file , NUM_ROLES
}
enum class  sarif_serialization_kind { json , num_values }
enum class  sarif_version { v2_1_0 , v2_2_prerelease_2024_08_08 , num_versions }

Functions

void default_text_starter (diagnostics::text_sink &, const diagnostics::diagnostic_info *)
template<typename TextOrHtml>
void default_start_span_fn (const diagnostics::location_print_policy &, TextOrHtml &text_or_html, expanded_location)
void default_text_finalizer (diagnostics::text_sink &, const diagnostics::diagnostic_info *, enum diagnostics::kind)
int num_digits (int)
const char * get_text_for_kind (enum kind kind)
const char * get_debug_string_for_kind (enum kind kind)
const char * get_color_for_kind (enum kind kind)
static int convert_column_unit (file_cache &fc, enum diagnostics_column_unit column_unit, int tabstop, expanded_location s)
static void print_escaped_string (pretty_printer *pp, const char *text)
static void print_parseable_fixits (file_cache &fc, pretty_printer *pp, rich_location *richloc, enum diagnostics_column_unit column_unit, int tabstop)
char * get_cwe_url (int cwe)
void output_format_init (context &dc, const char *main_input_filename_, const char *base_file_name, enum diagnostics_output_format format, bool json_formatting)
pretty_printerget_printer (to_text &)
text_starter_fntext_starter (context *dc)
start_span_fn< to_text > & start_span (context *dc)
text_finalizer_fntext_finalizer (context *dc)
static const char * default_charset_callback (const char *)
static const char * find_end_of_line (const char *s, size_t len)
static std::unique_ptr< xml::elementmake_div (std::string class_)
static std::unique_ptr< xml::elementmake_span (std::string class_)
static void add_nesting_level_attr (xml::element &element, int nesting_level)
static void print_pre_source (xml::printer &xp, const char *text)
static const char * get_pf_class_for_alert_div (enum kind diag_kind)
static const char * get_pf_class_for_alert_icon (enum kind diag_kind)
static const char * get_label_for_logical_location_kind (enum logical_locations::kind kind)
static void add_labelled_value (xml::printer &xp, std::string id, std::string label, std::string value, bool quote_value)
output_file open_html_output_file (context &dc, line_maps *line_maps, const char *base_file_name)
std::unique_ptr< sinkmake_html_sink (context &dc, const line_maps &line_maps, const html_generation_options &html_gen_opts, output_file output_file_)
void print_path_as_html (xml::printer &xp, const paths::path &path, context &dc, html_label_writer *event_label_writer, const source_print_policy &dspp)
void maybe_unwind_expanded_macro_loc (text_sink &text_output, location_t where)
void virt_loc_aware_text_finalizer (text_sink &text_output, const diagnostic_info *diagnostic)
static std::unique_ptr< json::stringmake_date_time_string_for_current_time ()
static const char * get_artifact_role_string (enum diagnostic_artifact_role role)
static const char * get_string_for_location_relationship_kind (enum location_relationship_kind kind)
static int bt_callback (void *data, uintptr_t pc, const char *filename, int lineno, const char *function)
static const char * maybe_get_sarif_level (enum kind diag_kind)
static char * make_rule_id_for_diagnostic_kind (enum kind diag_kind)
static char * make_pwd_uri_str ()
static const char * maybe_get_sarif_kind (enum logical_locations::kind kind)
static void copy_any_property_bag (const digraphs::object &input_obj, sarif_object &output_obj)
std::unique_ptr< sarif_graphmake_sarif_graph (const digraphs::digraph &g, sarif_builder *builder, sarif_location_manager *sarif_location_mgr)
std::unique_ptr< sarif_nodemake_sarif_node (const digraphs::node &n, sarif_builder *builder, sarif_location_manager *sarif_location_mgr)
std::unique_ptr< sarif_edgemake_sarif_edge (const digraphs::edge &e, sarif_builder *builder)
label_text make_sarif_url_for_event (const sarif_code_flow *code_flow, paths::event_id_t event_id)
static std::string escape_braces (const char *text)
static void set_string_property_escaping_braces (json::object &obj, const char *property_name, const char *value)
static const char * sarif_version_to_url (enum sarif_version version)
static const char * sarif_version_to_property (enum sarif_version version)
static void sarif_begin_embedded_link (pretty_printer *pp)
static void sarif_end_embedded_link (pretty_printer *pp, const char *url)
static sinkinit_sarif_sink (context &dc, std::unique_ptr< sarif_sink > fmt)
sinkinit_sarif_stderr (context &dc, const line_maps *line_maps, bool formatted)
output_file open_sarif_output_file (context &dc, line_maps *line_maps, const char *base_file_name, enum sarif_serialization_kind serialization_kind)
sinkinit_sarif_file (context &dc, line_maps *line_maps, bool formatted, const char *base_file_name)
sinkinit_sarif_stream (context &dc, const line_maps *line_maps, bool formatted, FILE *stream)
std::unique_ptr< sinkmake_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_)
static const char * get_dump_string_for_sarif_version (enum sarif_version version)
template<>
void default_start_span_fn< to_text > (const location_print_policy &loc_policy, to_text &out, expanded_location exploc)
template<>
void default_start_span_fn< to_html > (const location_print_policy &loc_policy, to_html &out, expanded_location exploc)
static unsigned get_bullet_point_unichar (bool unicode)
static bool use_unicode_p (const context &dc)
static unsigned get_bullet_point_unichar (context &dc)
void default_text_finalizer (text_sink &text_output, const diagnostic_info *diagnostic, enum kind)

Variables

static const char *const diagnostic_kind_text []
static const char *const diagnostic_kind_debug_text []
static const char *const diagnostic_kind_color []
static const char *const HTML_STYLE
const char *const HTML_SCRIPT
static const char *const bt_stop []

Detailed Description

Forward decl.   
Declarations relating to class gcc_rich_location
   Copyright (C) 2014-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/>.   
Declarations for variables relating to reading the source file.
   Used by parsers, lexical analyzers, and error message routines.
   Copyright (C) 1993-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/>.   
Default macros to initialize the lang_hooks data structure.
   Copyright (C) 2001-2025 Free Software Foundation, Inc.
   Contributed by Alexandre Oliva  <aoliva@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
The lang_hooks data structure.
   Copyright (C) 2001-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/>.   
FIXME: This file should be #include-d after tree.h (for enum tree_code).   
Support for buffering diagnostics before flushing them to output sinks.
   Copyright (C) 2024-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Determining the results of applying fix-it hints.
   Copyright (C) 2016-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/>.   
Additional metadata about a client for a diagnostic context.
   Copyright (C) 2022-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Options relating to the meaning of column numbers.
   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/>.   
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/>.   
Counts of per-kind diagnostics.
   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/>.   
Various declarations for language-independent diagnostics subroutines.
   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/>.   
Utilities for implementing "dump" functions for the diagnostics subsystem.
   Copyright (C) 2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Caching input files for use by diagnostics.
   Copyright (C) 2004-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/>.   
HTML output for diagnostics.
   Copyright (C) 2024-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
An enum used to discriminate severities of diagnostics.
   Copyright (C) 1998-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/>.   
Helper class for deferring path creation until a diagnostic is emitted.
   Copyright (C) 2024-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Debugging code for logging what the diagnostics subsystem is doing.
   Copyright (C) 2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Logical location support, without knowledge of "tree".
   Copyright (C) 2022-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Code for unwinding macro expansions in diagnostics.
   Copyright (C) 1999-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/>.   
Code for unwinding macro expansions in diagnostics.
   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/>.   
Additional metadata for a diagnostic.
   Copyright (C) 2019-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Stacks of set of classifications of diagnostics.
   Copyright (C) 1999-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/>.   
Stacks of set of classifications of diagnostics.
   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/>.   
Hooks for giving client-specific meaning to option ids.
   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/>.   
Declaration of struct diagnostics::option_id.
   Copyright (C) 2024-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
RAII class for managing FILE * for diagnostic formats.
   Copyright (C) 2024-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
A namespace for handling the DSL of the arguments of
-fdiagnostics-add-output= and -fdiagnostics-set-output=.   
Support for the DSL of -fdiagnostics-add-output= and
   -fdiagnostics-set-output=.
   Copyright (C) 2024-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/>.   
Paths through the code associated with a diagnostic.
   Copyright (C) 2019-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
SARIF output for diagnostics.
   Copyright (C) 2023-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Declarations for managing different output formats for diagnostics.
   Copyright (C) 2023-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Classes for adding special effects when quoting source code.
   Copyright (C) 2024-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Options relating to printing the user's source code.
   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/>.   
Disable warnings about quoting issues in the pp_xxx calls below
that (intentionally) don't follow GCC diagnostic conventions.   
Classic text-based output of diagnostics.
   Copyright (C) 2023-2025 Free Software Foundation, Inc.
   Contributed by David Malcolm <dmalcolm@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   

Typedef Documentation

◆ start_span_fn

template<typename TextOrHtml>
using diagnostics::start_span_fn
Initial value:
void (*) (const location_print_policy &,
TextOrHtml &text_or_html,
expanded_location)
Definition diagnostics/context.h:117

◆ text_finalizer_fn

typedef void(* diagnostics::text_finalizer_fn) (text_sink &, const diagnostic_info *, enum kind)

◆ text_starter_fn

typedef void(* diagnostics::text_starter_fn) (text_sink &, const diagnostic_info *)

Enumeration Type Documentation

◆ diagnostic_artifact_role

Corresponds to values for the SARIF artifact objects "roles" property.
(SARIF v2.1.0 section 3.24.6).   
Enumerator
analysis_target 
debug_output_file 
result_file 
scanned_file 
traced_file 
NUM_ROLES 

◆ kind

enum class diagnostics::kind
strong
Constants used to discriminate diagnostics.   
Enumerator
last_diagnostic_kind 
pop 
any 

◆ location_relationship_kind

Enumerator
includes 
is_included_by 
relevant 
NUM_KINDS 

◆ sarif_serialization_kind

Enum for choosing what format to serializing the generated SARIF into.   
Enumerator
json 
num_values 

◆ sarif_version

enum class diagnostics::sarif_version
strong
Control of SARIF generation.   
Enumerator
v2_1_0 
v2_2_prerelease_2024_08_08 
num_versions 

Function Documentation

◆ add_labelled_value()

void diagnostics::add_labelled_value ( xml::printer & xp,
std::string id,
std::string label,
std::string value,
bool quote_value )
static

◆ add_nesting_level_attr()

void diagnostics::add_nesting_level_attr ( xml::element & element,
int nesting_level )
static

◆ bt_callback()

int diagnostics::bt_callback ( void * data,
uintptr_t pc,
const char * filename,
int lineno,
const char * function )
static

◆ convert_column_unit()

int diagnostics::convert_column_unit ( file_cache & fc,
enum diagnostics_column_unit column_unit,
int tabstop,
expanded_location s )
static
Given an expanded_location, convert the column (which is in 1-based bytes)
to the requested units, without converting the origin.
Return -1 if the column is invalid (<= 0).   

References DIAGNOSTICS_COLUMN_UNIT_BYTE, DIAGNOSTICS_COLUMN_UNIT_DISPLAY, gcc_unreachable, and location_compute_display_column().

Referenced by diagnostics::column_options::convert_column(), and print_parseable_fixits().

◆ copy_any_property_bag()

◆ default_charset_callback()

const char * diagnostics::default_charset_callback ( const char * )
static
Input charset configuration.   

Referenced by diagnostics::file_cache::initialize_input_context().

◆ default_start_span_fn()

template<typename TextOrHtml>
void diagnostics::default_start_span_fn ( const diagnostics::location_print_policy & ,
TextOrHtml & text_or_html,
expanded_location  )

◆ default_start_span_fn< to_html >()

template<>
void diagnostics::default_start_span_fn< to_html > ( const location_print_policy & loc_policy,
to_html & out,
expanded_location exploc )

◆ default_start_span_fn< to_text >()

◆ default_text_finalizer() [1/2]

void diagnostics::default_text_finalizer ( diagnostics::text_sink & ,
const diagnostics::diagnostic_info * ,
enum diagnostics::kind  )

◆ default_text_finalizer() [2/2]

◆ default_text_starter()

◆ escape_braces()

std::string diagnostics::escape_braces ( const char * text)
static
In "3.11.5 Messages with placeholders":
"Within both plain text and formatted message strings, the characters
"{" and "}" SHALL be represented by the character sequences
"{{" and "}}" respectively."   

Referenced by set_string_property_escaping_braces().

◆ find_end_of_line()

const char * diagnostics::find_end_of_line ( const char * s,
size_t len )
static
Helper function for file_cache_slot::get_next_line (), to find the end of
the next line.  Returns with the memchr convention, i.e. nullptr if a line
terminator was not found.  We need to determine line endings in the same
manner that libcpp does: any of \n, \r\n, or \r is a line ending.   

References end().

Referenced by diagnostics::file_cache_slot::get_next_line().

◆ get_artifact_role_string()

const char * diagnostics::get_artifact_role_string ( enum diagnostic_artifact_role role)
static
Get a string for ROLE corresponding to the
SARIF v2.1.0 section 3.24.6 "roles" property.   

References analysis_target, debug_output_file, gcc_unreachable, result_file, scanned_file, and traced_file.

Referenced by diagnostics::sarif_artifact::populate_roles().

◆ get_bullet_point_unichar() [1/2]

unsigned diagnostics::get_bullet_point_unichar ( bool unicode)
static
Get the unicode code point for bullet points when showing
nested diagnostics.   

Referenced by diagnostics::text_sink::build_indent_prefix(), and get_bullet_point_unichar().

◆ get_bullet_point_unichar() [2/2]

unsigned diagnostics::get_bullet_point_unichar ( context & dc)
static
Get the unicode code point for bullet points when showing
nested diagnostics.   

References get_bullet_point_unichar(), and use_unicode_p().

◆ get_color_for_kind()

const char * diagnostics::get_color_for_kind ( enum kind kind)

◆ get_cwe_url()

char * diagnostics::get_cwe_url ( int cwe)
Generate a URL string describing CWE.  The caller is responsible for
freeing the string.   

Referenced by diagnostics::html_builder::make_element_for_metadata(), diagnostics::sarif_builder::make_reporting_descriptor_object_for_cwe_id(), and diagnostics::text_sink::print_any_cwe().

◆ get_debug_string_for_kind()

const char * diagnostics::get_debug_string_for_kind ( enum kind kind)

◆ get_dump_string_for_sarif_version()

const char * diagnostics::get_dump_string_for_sarif_version ( enum sarif_version version)
static

◆ get_label_for_logical_location_kind()

◆ get_pf_class_for_alert_div()

const char * diagnostics::get_pf_class_for_alert_div ( enum kind diag_kind)
static
See https://pf3.patternfly.org/v3/pattern-library/widgets/#alerts  

References gcc_unreachable.

Referenced by diagnostics::html_builder::make_element_for_diagnostic().

◆ get_pf_class_for_alert_icon()

const char * diagnostics::get_pf_class_for_alert_icon ( enum kind diag_kind)
static

◆ get_printer()

◆ get_string_for_location_relationship_kind()

const char * diagnostics::get_string_for_location_relationship_kind ( enum location_relationship_kind kind)
static

◆ get_text_for_kind()

const char * diagnostics::get_text_for_kind ( enum kind kind)

◆ init_sarif_file()

sink & diagnostics::init_sarif_file ( context & dc,
line_maps * line_maps,
bool formatted,
const char * base_file_name )
Populate DC in preparation for SARIF output to a file named
BASE_FILE_NAME.sarif.
Return a reference to the new sink.   

References base_file_name(), gcc_assert, init_sarif_sink(), json, and open_sarif_output_file().

Referenced by output_format_init().

◆ init_sarif_sink()

sink & diagnostics::init_sarif_sink ( context & dc,
std::unique_ptr< sarif_sink > fmt )
static
Populate CONTEXT in preparation for SARIF output (either to stderr, or
to a file).
Return a reference to *FMT.   

References gcc_assert, diagnostics::context::set_sink(), and diagnostics::sink::update_printer().

Referenced by init_sarif_file(), init_sarif_stderr(), and init_sarif_stream().

◆ init_sarif_stderr()

sink & diagnostics::init_sarif_stderr ( context & dc,
const line_maps * line_maps,
bool formatted )
Populate DC in preparation for SARIF output to stderr.
Return a reference to the new sink.   

References gcc_assert, and init_sarif_sink().

Referenced by output_format_init().

◆ init_sarif_stream()

sink & diagnostics::init_sarif_stream ( context & dc,
const line_maps * line_maps,
bool formatted,
FILE * stream )
Populate DC in preparation for SARIF output to STREAM.
Return a reference to the new sink.   

References gcc_assert, and init_sarif_sink().

◆ make_date_time_string_for_current_time()

std::unique_ptr< json::string > diagnostics::make_date_time_string_for_current_time ( )
static
Make a JSON string for the current date and time.
See SARIF v2.1.0 section 3.9 "Date/time properties".
Given that we don't run at the very beginning/end of the
process, it doesn't make sense to be more accurate than
the current second.   

Referenced by diagnostics::sarif_invocation::prepare_to_flush(), and diagnostics::sarif_invocation::sarif_invocation().

◆ make_div()

std::unique_ptr< xml::element > diagnostics::make_div ( std::string class_)
static

◆ make_html_sink()

std::unique_ptr< sink > diagnostics::make_html_sink ( context & dc,
const line_maps & line_maps,
const html_generation_options & html_gen_opts,
output_file output_file_ )

◆ make_pwd_uri_str()

char * diagnostics::make_pwd_uri_str ( )
static
Get the PWD, or nullptr, as an absolute file-based URI,
adding a trailing forward slash (as required by SARIF v2.1.0
section 3.14.14).   

References FILE_PREFIX, and gcc_assert.

Referenced by diagnostics::sarif_builder::make_artifact_location_object_for_pwd().

◆ make_rule_id_for_diagnostic_kind()

char * diagnostics::make_rule_id_for_diagnostic_kind ( enum kind diag_kind)
static
Make a string for DIAG_KIND suitable for use a ruleId
(SARIF v2.1.0 section 3.27.5) as a fallback for when we don't
have anything better to use.   

References gcc_assert, and get_text_for_kind().

Referenced by diagnostics::sarif_builder::make_result_object().

◆ make_sarif_edge()

std::unique_ptr< sarif_edge > diagnostics::make_sarif_edge ( const digraphs::edge & e,
sarif_builder * builder )

◆ make_sarif_graph()

◆ make_sarif_node()

◆ make_sarif_sink()

std::unique_ptr< sink > diagnostics::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_ )

◆ make_sarif_url_for_event()

◆ make_span()

◆ maybe_get_sarif_kind()

◆ maybe_get_sarif_level()

const char * diagnostics::maybe_get_sarif_level ( enum kind diag_kind)
static
Attempt to convert DIAG_KIND to a suitable value for the "level"
property (SARIF v2.1.0 section 3.27.10).

Return nullptr if there isn't one.   

Referenced by diagnostics::sarif_builder::make_result_object().

◆ maybe_unwind_expanded_macro_loc()

void diagnostics::maybe_unwind_expanded_macro_loc ( text_sink & text_output,
location_t where )
Unwind the different macro expansions that lead to the token which
location is WHERE and emit diagnostics showing the resulting
unwound macro expansion trace.  Let's look at an example to see how
the trace looks like.  Suppose we have this piece of code,
artificially annotated with the line numbers to increase
legibility:

 $ cat -n test.c
   1    #define OPERATE(OPRD1, OPRT, OPRD2) \
   2      OPRD1 OPRT OPRD2;
   3
   4    #define SHIFTL(A,B) \
   5      OPERATE (A,<<,B)
   6
   7    #define MULT(A) \
   8      SHIFTL (A,1)
   9
  10    void
  11    g ()
  12    {
  13      MULT (1.0);// 1.0 << 1; <-- so this is an error.
  14    }

Here is the diagnostic that we want the compiler to generate:

 test.c: In function ‘g’:
 test.c:5:14: error: invalid operands to binary << (have ‘double’ and ‘int’)
 test.c:2:9: note: in definition of macro 'OPERATE'
 test.c:8:3: note: in expansion of macro 'SHIFTL'
 test.c:13:3: note: in expansion of macro 'MULT'

The part that goes from the third to the fifth line of this
diagnostic (the lines containing the 'note:' string) is called the
unwound macro expansion trace.  That's the part generated by this
function.   

References diagnostics::text_sink::append_note(), expand_location_to_spelling_point(), FOR_EACH_VEC_ELT, line_table, diagnostics::loc_map_pair::map, map, and diagnostics::loc_map_pair::where.

Referenced by virt_loc_aware_text_finalizer().

◆ num_digits()

int diagnostics::num_digits ( int value)
extern
Compute the number of digits in the decimal representation of an integer.   
Get the number of digits in the decimal representation of VALUE.   

References gcc_assert, and diagnostics::logical_locations::value.

Referenced by dump_location_info().

◆ open_html_output_file()

diagnostics::output_file diagnostics::open_html_output_file ( context & dc,
line_maps * line_maps,
const char * base_file_name )
Attempt to open BASE_FILE_NAME.html for writing.
Return a non-null output_file,
or return a null output_file and complain to DC
using LINE_MAPS.   

References base_file_name(), diagnostics::context::emit_diagnostic_with_group(), fopen, output_file, and UNKNOWN_LOCATION.

Referenced by diagnostics::output_spec::html_scheme_handler::make_sink().

◆ open_sarif_output_file()

output_file diagnostics::open_sarif_output_file ( context & dc,
line_maps * line_maps,
const char * base_file_name,
enum sarif_serialization_kind serialization_kind )
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 DC
using LINE_MAPS.   

References base_file_name(), gcc_unreachable, json, and diagnostics::output_file::try_to_open().

Referenced by init_sarif_file(), and diagnostics::output_spec::sarif_scheme_handler::make_sink().

◆ output_format_init()

void diagnostics::output_format_init ( context & dc,
const char * main_input_filename_,
const char * base_file_name,
enum diagnostics_output_format format,
bool json_formatting )

◆ print_escaped_string()

void diagnostics::print_escaped_string ( pretty_printer * pp,
const char * text )
static
Helper function for print_parseable_fixits.  Print TEXT to PP, obeying the
escaping rules for -fdiagnostics-parseable-fixits.   

References gcc_assert, pp_character(), pp_printf(), pp_string(), and diagnostics::logical_locations::text.

Referenced by print_parseable_fixits().

◆ print_parseable_fixits()

void diagnostics::print_parseable_fixits ( file_cache & fc,
pretty_printer * pp,
rich_location * richloc,
enum diagnostics_column_unit column_unit,
int tabstop )
static
Implementation of -fdiagnostics-parseable-fixits and
GCC_EXTRA_DIAGNOSTIC_OUTPUT.
Print a machine-parseable version of all fixits in RICHLOC to PP,
using COLUMN_UNIT to express columns.
Use TABSTOP when handling DIAGNOSTICS_COLUMN_UNIT_DISPLAY.   

References convert_column_unit(), expand_location(), gcc_assert, i, pp_newline(), pp_printf(), pp_set_prefix(), pp_string(), pp_take_prefix(), and print_escaped_string().

Referenced by diagnostics::context::report_diagnostic().

◆ print_path_as_html()

void diagnostics::print_path_as_html ( xml::printer & xp,
const paths::path & path,
context & dc,
html_label_writer * event_label_writer,
const source_print_policy & dspp )
extern

◆ print_pre_source()

void diagnostics::print_pre_source ( xml::printer & xp,
const char * text )
static

◆ sarif_begin_embedded_link()

void diagnostics::sarif_begin_embedded_link ( pretty_printer * pp)
static
Print the start of an embedded link to PP, as per 3.11.6.   

References pp_character().

Referenced by diagnostics::sarif_builder::sarif_token_printer::print_tokens().

◆ sarif_end_embedded_link()

void diagnostics::sarif_end_embedded_link ( pretty_printer * pp,
const char * url )
static
Print the end of an embedded link to PP, as per 3.11.6.   

References pp_character(), and pp_string().

Referenced by diagnostics::sarif_builder::sarif_token_printer::print_tokens().

◆ sarif_version_to_property()

const char * diagnostics::sarif_version_to_property ( enum sarif_version version)
static
Convert VERSION to a value for the "version" property
of a "sarifLog" object (SARIF v2.1.0 section 3.13.2).   

References gcc_unreachable, v2_1_0, and v2_2_prerelease_2024_08_08.

Referenced by diagnostics::sarif_builder::make_top_level_object().

◆ sarif_version_to_url()

const char * diagnostics::sarif_version_to_url ( enum sarif_version version)
static
Convert VERSION to a value for the "$schema" property
of a "sarifLog" object (SARIF v2.1.0 section 3.13.3).   

References gcc_unreachable, v2_1_0, and v2_2_prerelease_2024_08_08.

Referenced by diagnostics::sarif_builder::make_top_level_object().

◆ set_string_property_escaping_braces()

void diagnostics::set_string_property_escaping_braces ( json::object & obj,
const char * property_name,
const char * value )
static

◆ start_span()

start_span_fn< to_text > & diagnostics::start_span ( context * dc)
inline
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.   

◆ text_finalizer()

text_finalizer_fn & diagnostics::text_finalizer ( context * dc)
inline
Client supplied function called after a diagnostic message is
displayed (for text-based diagnostic output).   

Referenced by diagnostics::text_sink::on_report_diagnostic(), and tree_diagnostics_defaults().

◆ text_starter()

text_starter_fn & diagnostics::text_starter ( context * dc)
inline
Client supplied function to announce a diagnostic
(for text-based diagnostic output).   

Referenced by diagnostic_manager::diagnostic_manager(), diagnostics::text_sink::on_report_diagnostic(), and tree_diagnostics_defaults().

◆ use_unicode_p()

bool diagnostics::use_unicode_p ( const context & dc)
static
Return true if DC's theme supports unicode characters.   

References diagnostics::context::get_diagram_theme().

Referenced by get_bullet_point_unichar().

◆ virt_loc_aware_text_finalizer()

void diagnostics::virt_loc_aware_text_finalizer ( text_sink & text_output,
const diagnostic_info * diagnostic )
This is a diagnostic finalizer implementation that is aware of
virtual locations produced by libcpp.

It has to be called by the diagnostic finalizer of front ends that
uses libcpp and wish to get diagnostics involving tokens resulting
from macro expansion.

For a given location, if said location belongs to a token
resulting from a macro expansion, this starter prints the context
of the token.  E.g, for multiply nested macro expansion, it
unwinds the nested macro expansions and prints them in a manner
that is similar to what is done for function call stacks, or
template instantiation contexts.   

References diagnostic_location(), and maybe_unwind_expanded_macro_loc().

Variable Documentation

◆ bt_stop

const char* const diagnostics::bt_stop[]
static
Initial value:
=
{
"main",
"toplev::main",
"execute_one_pass",
"compile_file",
}
Functions at which to stop the backtrace print.  It's not
particularly helpful to print the callers of these functions.   

Referenced by bt_callback().

◆ diagnostic_kind_color

const char* const diagnostics::diagnostic_kind_color[]
static
Initial value:
= {
#define DEFINE_DIAGNOSTIC_KIND(K, T, C)
nullptr
}

Referenced by get_color_for_kind().

◆ diagnostic_kind_debug_text

const char* const diagnostics::diagnostic_kind_debug_text[]
static
Initial value:
= {
#define DEFINE_DIAGNOSTIC_KIND(K, T, C)
"must-not-happen"
}

Referenced by get_debug_string_for_kind().

◆ diagnostic_kind_text

const char* const diagnostics::diagnostic_kind_text[]
static
Initial value:
= {
#define DEFINE_DIAGNOSTIC_KIND(K, T, C)
"must-not-happen"
}

Referenced by get_text_for_kind().

◆ HTML_SCRIPT

const char* const diagnostics::HTML_SCRIPT
A little JavaScript for ease of navigation.
Keys j/k move forward and backward cyclically through a list
of focus ids (written out in another <script> tag as the HTML
is flushed).   

◆ HTML_STYLE

const char* const diagnostics::HTML_STYLE
static
class html_builder.   
Style information for writing out HTML paths.
Colors taken from https://pf3.patternfly.org/v3/styles/color-palette/