Line data Source code
1 : /* Command line option handling. Interactions with diagnostics code.
2 : Copyright (C) 2010-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_OPTS_DIAGNOSTIC_H
21 : #define GCC_OPTS_DIAGNOSTIC_H
22 :
23 : #include "diagnostics/sink.h"
24 :
25 : /* Abstract subclass of diagnostics::option_id_manager for gcc options. */
26 :
27 : class gcc_diagnostic_option_id_manager : public diagnostics::option_id_manager
28 : {
29 : public:
30 : label_text
31 : get_option_url (diagnostics::option_id option_id) const final override;
32 :
33 : protected:
34 309962 : gcc_diagnostic_option_id_manager (unsigned lang_mask)
35 309962 : : m_lang_mask (lang_mask)
36 : {}
37 :
38 : unsigned m_lang_mask;
39 : };
40 :
41 : /* Concrete implementation of diagnostics::option_id_manager for compiler. */
42 :
43 : class compiler_diagnostic_option_id_manager
44 : : public gcc_diagnostic_option_id_manager
45 : {
46 : public:
47 297180 : compiler_diagnostic_option_id_manager (const diagnostics::context &context,
48 : unsigned lang_mask,
49 : void *opts)
50 : : gcc_diagnostic_option_id_manager (lang_mask),
51 297180 : m_context (context),
52 297180 : m_opts (opts)
53 : {
54 : }
55 :
56 : int option_enabled_p (diagnostics::option_id option_id) const final override;
57 :
58 : label_text
59 : get_option_name (diagnostics::option_id option_id,
60 : enum diagnostics::kind orig_diag_kind,
61 : enum diagnostics::kind diag_kind) const final override;
62 :
63 : private:
64 : const diagnostics::context &m_context;
65 : void *m_opts;
66 : };
67 :
68 : class gcc_extension_factory
69 : {
70 : public:
71 : virtual ~gcc_extension_factory () {}
72 :
73 : virtual std::unique_ptr<diagnostics::sink::extension>
74 : make_cfg_extension (diagnostics::sink &sink) const = 0;
75 :
76 : virtual std::unique_ptr<diagnostics::sink::extension>
77 : make_analyzer_graphs_extension (diagnostics::sink &sink) const = 0;
78 :
79 : static const gcc_extension_factory *singleton;
80 : };
81 :
82 :
83 : extern void
84 : handle_OPT_fdiagnostics_add_output_ (const gcc_options &opts,
85 : diagnostics::context &dc,
86 : const char *arg,
87 : location_t loc);
88 :
89 : extern void
90 : handle_OPT_fdiagnostics_set_output_ (const gcc_options &opts,
91 : diagnostics::context &dc,
92 : const char *arg,
93 : location_t loc);
94 :
95 : extern const char *
96 : get_diagnostic_file_output_basename (const gcc_options &opts);
97 :
98 : #endif
|