libstdc++: Refactor loops in std::__platform_semaphore
[official-gcc.git] / gcc / diagnostic-format.h
blob688ddcaaf4301990e670882a4ed18e1747e68868
1 /* Declarations for managing different output formats for diagnostics.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_DIAGNOSTIC_FORMAT_H
22 #define GCC_DIAGNOSTIC_FORMAT_H
24 /* Abstract base class for a particular output format for diagnostics;
25 each value of -fdiagnostics-output-format= will have its own
26 implementation. */
28 class diagnostic_output_format
30 public:
31 virtual ~diagnostic_output_format () {}
33 virtual void on_begin_group () = 0;
34 virtual void on_end_group () = 0;
36 /* Vfunc with responsibility for phase 3 of formatting the message
37 and "printing" the result. */
38 virtual void on_report_diagnostic (const diagnostic_info &,
39 diagnostic_t orig_diag_kind) = 0;
41 virtual void on_diagram (const diagnostic_diagram &diagram) = 0;
42 virtual bool machine_readable_stderr_p () const = 0;
44 pretty_printer *get_printer () const { return m_context.m_printer; }
46 protected:
47 diagnostic_output_format (diagnostic_context &context)
48 : m_context (context)
51 diagnostic_context &m_context;
54 extern void
55 diagnostic_output_format_init (diagnostic_context &,
56 const char *main_input_filename_,
57 const char *base_file_name,
58 enum diagnostics_output_format,
59 bool json_formatting);
60 extern void
61 diagnostic_output_format_init_json_stderr (diagnostic_context &context,
62 bool formatted);
63 extern void
64 diagnostic_output_format_init_json_file (diagnostic_context &context,
65 bool formatted,
66 const char *base_file_name);
67 extern void
68 diagnostic_output_format_init_sarif_stderr (diagnostic_context &context,
69 const line_maps *line_maps,
70 const char *main_input_filename_,
71 bool formatted);
72 extern void
73 diagnostic_output_format_init_sarif_file (diagnostic_context &context,
74 const line_maps *line_maps,
75 const char *main_input_filename_,
76 bool formatted,
77 const char *base_file_name);
78 extern void
79 diagnostic_output_format_init_sarif_stream (diagnostic_context &context,
80 const line_maps *line_maps,
81 const char *main_input_filename_,
82 bool formatted,
83 FILE *stream);
85 #endif /* ! GCC_DIAGNOSTIC_FORMAT_H */