tree-object-size: use size_for_offset in more cases
[official-gcc.git] / gcc / diagnostic-format.h
blob1fd3fe0c64e859bc2b731b5d93aa1ff45f6f0389
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 #include "diagnostic.h"
26 /* Abstract base class for a particular output format for diagnostics;
27 each value of -fdiagnostics-output-format= will have its own
28 implementation. */
30 class diagnostic_output_format
32 public:
33 virtual ~diagnostic_output_format () {}
35 virtual void on_begin_group () = 0;
36 virtual void on_end_group () = 0;
38 /* Vfunc with responsibility for phase 3 of formatting the message
39 and "printing" the result. */
40 virtual void on_report_diagnostic (const diagnostic_info &,
41 diagnostic_t orig_diag_kind) = 0;
43 virtual void on_diagram (const diagnostic_diagram &diagram) = 0;
44 virtual void after_diagnostic (const diagnostic_info &) = 0;
45 virtual bool machine_readable_stderr_p () const = 0;
47 diagnostic_context &get_context () const { return m_context; }
48 pretty_printer *get_printer () const { return m_context.m_printer; }
50 text_art::theme *get_diagram_theme () const
52 return m_context.get_diagram_theme ();
55 protected:
56 diagnostic_output_format (diagnostic_context &context)
57 : m_context (context)
60 diagnostic_context &m_context;
63 extern void
64 diagnostic_output_format_init (diagnostic_context &,
65 const char *main_input_filename_,
66 const char *base_file_name,
67 enum diagnostics_output_format,
68 bool json_formatting);
69 extern void
70 diagnostic_output_format_init_json_stderr (diagnostic_context &context,
71 bool formatted);
72 extern void
73 diagnostic_output_format_init_json_file (diagnostic_context &context,
74 bool formatted,
75 const char *base_file_name);
77 #endif /* ! GCC_DIAGNOSTIC_FORMAT_H */