OpenMP: Update documentation of metadirective implementation status.
[gcc.git] / gcc / diagnostic-buffer.h
blobe766a3b46ffb60190b00a289007b27505a7e5682
1 /* Support for buffering diagnostics before flushing them to output format.
2 Copyright (C) 2024-2025 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_BUFFER_H
22 #define GCC_DIAGNOSTIC_BUFFER_H
24 #include "diagnostic.h"
26 class diagnostic_per_format_buffer;
27 class diagnostic_output_format;
28 class diagnostic_text_output_format;
30 /* Class representing a buffer of zero or more diagnostics that
31 have been reported to a diagnostic_context, but which haven't
32 yet been flushed.
34 A diagnostic_buffer can be:
36 * flushed to the diagnostic_context, which issues
37 the diagnostics within the buffer to the output format
38 and checks for limits such as -fmax-errors=, or
40 * moved to another diagnostic_buffer, which moves the diagnostics
41 within the first buffer to the other buffer, appending them after any
42 existing diagnostics within the destination buffer, emptying the
43 source buffer, or
45 * cleared, which discards any diagnostics within the buffer
46 without issuing them to the output format.
48 Since a buffer needs to contain output-format-specific data,
49 it's not possible to change the output format of the
50 diagnostic_context once any buffers are non-empty.
52 To simplify implementing output formats, it's not possible
53 to change buffering on a diagnostic_context whilst within a
54 diagnostic group. */
56 class diagnostic_buffer
58 public:
59 friend class diagnostic_context;
61 diagnostic_buffer (diagnostic_context &ctxt);
62 ~diagnostic_buffer ();
64 void dump (FILE *out, int indent) const;
65 void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
67 int diagnostic_count (diagnostic_t kind) const
69 return m_diagnostic_counters.get_count (kind);
72 bool empty_p () const;
74 void move_to (diagnostic_buffer &dest);
76 private:
77 void ensure_per_format_buffers ();
79 diagnostic_context &m_ctxt;
80 auto_vec<diagnostic_per_format_buffer *> *m_per_format_buffers;
82 /* The number of buffered diagnostics of each kind. */
83 diagnostic_counters m_diagnostic_counters;
86 /* Implementation detail of diagnostic_buffer.
88 Abstract base class describing how to represent zero of more
89 buffered diagnostics for a particular diagnostic_output_format
90 (e.g. text vs SARIF).
92 Each diagnostic_output_format subclass should implement its own
93 subclass for handling diagnostic_buffer. */
95 class diagnostic_per_format_buffer
97 public:
98 virtual ~diagnostic_per_format_buffer () {}
100 virtual void dump (FILE *out, int indent) const = 0;
101 void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
103 virtual bool empty_p () const = 0;
104 virtual void move_to (diagnostic_per_format_buffer &dest) = 0;
105 virtual void clear () = 0;
106 virtual void flush () = 0;
109 #endif /* ! GCC_DIAGNOSTIC_BUFFER_H */