https://gcc.gnu.org/g:8aa544179dc971ac9af364ced5f128581ed09843
commit r16-2549-g8aa544179dc971ac9af364ced5f128581ed09843 Author: David Malcolm <dmalc...@redhat.com> Date: Fri Jul 25 15:13:44 2025 -0400 diagnostics: introduce context-options.h No functional change intended. gcc/ChangeLog: * diagnostic.h (enum diagnostics_column_unit): Move to diagnostics/context-options.h. (enum diagnostics_escape_format): Likewise. (enum diagnostics_output_format): Likewise. (enum diagnostic_path_format): Likewise. (enum diagnostics_extra_output_kind): Likewise. (enum diagnostic_text_art_charset): Likewise. * diagnostics/context-options.h: New file, based on the above material. * diagnostics/context.h: Include it. Signed-off-by: David Malcolm <dmalc...@redhat.com> Diff: --- gcc/diagnostic.h | 93 ------------------------------ gcc/diagnostics/context-options.h | 116 ++++++++++++++++++++++++++++++++++++++ gcc/diagnostics/context.h | 1 + 3 files changed, 117 insertions(+), 93 deletions(-) diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 6f2e77031acf..5d9751469e0b 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -28,99 +28,6 @@ along with GCC; see the file COPYING3. If not see #include "diagnostics/diagnostic-info.h" typedef diagnostics::diagnostic_info diagnostic_info; -/* An enum for controlling what units to use for the column number - when diagnostics are output, used by the -fdiagnostics-column-unit option. - Tabs will be expanded or not according to the value of -ftabstop. The origin - (default 1) is controlled by -fdiagnostics-column-origin. */ - -enum diagnostics_column_unit -{ - /* The default from GCC 11 onwards: display columns. */ - DIAGNOSTICS_COLUMN_UNIT_DISPLAY, - - /* The behavior in GCC 10 and earlier: simple bytes. */ - DIAGNOSTICS_COLUMN_UNIT_BYTE -}; - -/* An enum for controlling how to print non-ASCII characters/bytes when - a diagnostic suggests escaping the source code on output. */ - -enum diagnostics_escape_format -{ - /* Escape non-ASCII Unicode characters in the form <U+XXXX> and - non-UTF-8 bytes in the form <XX>. */ - DIAGNOSTICS_ESCAPE_FORMAT_UNICODE, - - /* Escape non-ASCII bytes in the form <XX> (thus showing the underlying - encoding of non-ASCII Unicode characters). */ - DIAGNOSTICS_ESCAPE_FORMAT_BYTES -}; - -/* Enum for overriding the standard output format. */ - -enum diagnostics_output_format -{ - /* The default: textual output. */ - DIAGNOSTICS_OUTPUT_FORMAT_TEXT, - - /* SARIF-based output, as JSON to stderr. */ - DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR, - - /* SARIF-based output, to a JSON file. */ - DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE -}; - -/* An enum for controlling how diagnostic paths should be printed. */ -enum diagnostic_path_format -{ - /* Don't print diagnostic paths. */ - DPF_NONE, - - /* Print diagnostic paths by emitting a separate "note" for every event - in the path. */ - DPF_SEPARATE_EVENTS, - - /* Print diagnostic paths by consolidating events together where they - are close enough, and printing such runs of events with multiple - calls to diagnostic_show_locus, showing the individual events in - each run via labels in the source. */ - DPF_INLINE_EVENTS -}; - -/* An enum for capturing values of GCC_EXTRA_DIAGNOSTIC_OUTPUT, - and for -fdiagnostics-parseable-fixits. */ - -enum diagnostics_extra_output_kind -{ - /* No extra output, or an unrecognized value. */ - EXTRA_DIAGNOSTIC_OUTPUT_none, - - /* Emit fix-it hints using the "fixits-v1" format, equivalent to - -fdiagnostics-parseable-fixits. */ - EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1, - - /* Emit fix-it hints using the "fixits-v2" format. */ - EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2 -}; - -/* Values for -fdiagnostics-text-art-charset=. */ - -enum diagnostic_text_art_charset -{ - /* No text art diagrams shall be emitted. */ - DIAGNOSTICS_TEXT_ART_CHARSET_NONE, - - /* Use pure ASCII for text art diagrams. */ - DIAGNOSTICS_TEXT_ART_CHARSET_ASCII, - - /* Use ASCII + conservative use of other unicode characters - in text art diagrams. */ - DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE, - - /* Use Emoji. */ - DIAGNOSTICS_TEXT_ART_CHARSET_EMOJI -}; - #include "diagnostics/context.h" /* Extension hooks for client. */ diff --git a/gcc/diagnostics/context-options.h b/gcc/diagnostics/context-options.h new file mode 100644 index 000000000000..c4e92eb41c95 --- /dev/null +++ b/gcc/diagnostics/context-options.h @@ -0,0 +1,116 @@ +/* Declare enums for 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_OPTIONS_H +#define GCC_DIAGNOSTICS_CONTEXT_OPTIONS_H + +/* An enum for controlling what units to use for the column number + when diagnostics are output, used by the -fdiagnostics-column-unit option. + Tabs will be expanded or not according to the value of -ftabstop. The origin + (default 1) is controlled by -fdiagnostics-column-origin. */ + +enum diagnostics_column_unit +{ + /* The default from GCC 11 onwards: display columns. */ + DIAGNOSTICS_COLUMN_UNIT_DISPLAY, + + /* The behavior in GCC 10 and earlier: simple bytes. */ + DIAGNOSTICS_COLUMN_UNIT_BYTE +}; + +/* An enum for controlling how to print non-ASCII characters/bytes when + a diagnostic suggests escaping the source code on output. */ + +enum diagnostics_escape_format +{ + /* Escape non-ASCII Unicode characters in the form <U+XXXX> and + non-UTF-8 bytes in the form <XX>. */ + DIAGNOSTICS_ESCAPE_FORMAT_UNICODE, + + /* Escape non-ASCII bytes in the form <XX> (thus showing the underlying + encoding of non-ASCII Unicode characters). */ + DIAGNOSTICS_ESCAPE_FORMAT_BYTES +}; + +/* Enum for overriding the standard output format. */ + +enum diagnostics_output_format +{ + /* The default: textual output. */ + DIAGNOSTICS_OUTPUT_FORMAT_TEXT, + + /* SARIF-based output, as JSON to stderr. */ + DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR, + + /* SARIF-based output, to a JSON file. */ + DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE +}; + +/* An enum for controlling how diagnostic paths should be printed. */ +enum diagnostic_path_format +{ + /* Don't print diagnostic paths. */ + DPF_NONE, + + /* Print diagnostic paths by emitting a separate "note" for every event + in the path. */ + DPF_SEPARATE_EVENTS, + + /* Print diagnostic paths by consolidating events together where they + are close enough, and printing such runs of events with multiple + calls to diagnostic_show_locus, showing the individual events in + each run via labels in the source. */ + DPF_INLINE_EVENTS +}; + +/* An enum for capturing values of GCC_EXTRA_DIAGNOSTIC_OUTPUT, + and for -fdiagnostics-parseable-fixits. */ + +enum diagnostics_extra_output_kind +{ + /* No extra output, or an unrecognized value. */ + EXTRA_DIAGNOSTIC_OUTPUT_none, + + /* Emit fix-it hints using the "fixits-v1" format, equivalent to + -fdiagnostics-parseable-fixits. */ + EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1, + + /* Emit fix-it hints using the "fixits-v2" format. */ + EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2 +}; + +/* Values for -fdiagnostics-text-art-charset=. */ + +enum diagnostic_text_art_charset +{ + /* No text art diagrams shall be emitted. */ + DIAGNOSTICS_TEXT_ART_CHARSET_NONE, + + /* Use pure ASCII for text art diagrams. */ + DIAGNOSTICS_TEXT_ART_CHARSET_ASCII, + + /* Use ASCII + conservative use of other unicode characters + in text art diagrams. */ + DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE, + + /* Use Emoji. */ + DIAGNOSTICS_TEXT_ART_CHARSET_EMOJI +}; + +#endif /* ! GCC_DIAGNOSTICS_CONTEXT_OPTIONS_H */ diff --git a/gcc/diagnostics/context.h b/gcc/diagnostics/context.h index cd8b340f173a..835403e5c8b5 100644 --- a/gcc/diagnostics/context.h +++ b/gcc/diagnostics/context.h @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #include "unique-argv.h" #include "diagnostics/option-classifier.h" +#include "diagnostics/context-options.h" namespace diagnostics {