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 : char *make_option_url (diagnostics::option_id option_id) const final override;
31 :
32 : protected:
33 297924 : gcc_diagnostic_option_id_manager (unsigned lang_mask)
34 297924 : : m_lang_mask (lang_mask)
35 : {}
36 :
37 : unsigned m_lang_mask;
38 : };
39 :
40 : /* Concrete implementation of diagnostics::option_id_manager for compiler. */
41 :
42 : class compiler_diagnostic_option_id_manager
43 : : public gcc_diagnostic_option_id_manager
44 : {
45 : public:
46 285722 : compiler_diagnostic_option_id_manager (const diagnostics::context &context,
47 : unsigned lang_mask,
48 : void *opts)
49 285722 : : gcc_diagnostic_option_id_manager (lang_mask),
50 285722 : m_context (context),
51 285722 : m_opts (opts)
52 : {
53 : }
54 :
55 : int option_enabled_p (diagnostics::option_id option_id) const final override;
56 : char *
57 : make_option_name (diagnostics::option_id option_id,
58 : enum diagnostics::kind orig_diag_kind,
59 : enum diagnostics::kind diag_kind) const final override;
60 :
61 : private:
62 : const diagnostics::context &m_context;
63 : void *m_opts;
64 : };
65 :
66 : class gcc_extension_factory
67 : {
68 : public:
69 : virtual ~gcc_extension_factory () {}
70 :
71 : virtual std::unique_ptr<diagnostics::sink::extension>
72 : make_cfg_extension (diagnostics::sink &sink) const = 0;
73 :
74 : static const gcc_extension_factory *singleton;
75 : };
76 :
77 :
78 : extern void
79 : handle_OPT_fdiagnostics_add_output_ (const gcc_options &opts,
80 : diagnostics::context &dc,
81 : const char *arg,
82 : location_t loc);
83 :
84 : extern void
85 : handle_OPT_fdiagnostics_set_output_ (const gcc_options &opts,
86 : diagnostics::context &dc,
87 : const char *arg,
88 : location_t loc);
89 :
90 : extern const char *
91 : get_diagnostic_file_output_basename (const gcc_options &opts);
92 :
93 : #endif
|