Line data Source code
1 : /* Counts of per-kind diagnostics.
2 : Copyright (C) 2000-2026 Free Software Foundation, Inc.
3 :
4 : This file is part of GCC.
5 :
6 : GCC is free software; you can redistribute it and/or modify it under
7 : the terms of the GNU General Public License as published by the Free
8 : Software Foundation; either version 3, or (at your option) any later
9 : version.
10 :
11 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along with GCC; see the file COPYING3. If not see
18 : <http://www.gnu.org/licenses/>. */
19 :
20 : #ifndef GCC_DIAGNOSTICS_COUNTERS_H
21 : #define GCC_DIAGNOSTICS_COUNTERS_H
22 :
23 : #include "diagnostics/kinds.h"
24 :
25 : namespace diagnostics {
26 :
27 : /* A collection of counters of diagnostics, per-kind
28 : (e.g. "3 errors and 1 warning"), for use by both diagnostics::context
29 : and by diagnostics::buffer. */
30 :
31 : struct counters
32 : {
33 : counters ();
34 :
35 : void dump (FILE *out, int indent) const;
36 0 : void DEBUG_FUNCTION dump () const { dump (stderr, 0); }
37 :
38 1093036 : int get_count (enum kind kind) const
39 : {
40 291358 : return m_count_for_kind[static_cast<size_t> (kind)];
41 : }
42 :
43 : void move_to (counters &dest);
44 : void clear ();
45 :
46 : int m_count_for_kind[static_cast<size_t> (kind::last_diagnostic_kind)];
47 : };
48 :
49 : } // namespace diagnostics
50 :
51 : #endif /* ! GCC_DIAGNOSTICS_COUNTERS_H */
|