Allow target to override gnu-user.h crti and crtn
[official-gcc.git] / gcc / opt-suggestions.h
blobeb932779939375083935751f5adf3b4cc35cc86c
1 /* Provide suggestions to handle misspelled options, and implement the
2 --complete option for auto-completing options from a prefix.
3 Copyright (C) 2016-2018 Free Software Foundation, Inc.
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_OPT_PROPOSER_H
22 #define GCC_OPT_PROPOSER_H
24 /* Option proposer is class used by driver in order to provide hints
25 for wrong options provided. And it's used by --complete option that's
26 intended to be invoked by BASH in order to provide better option
27 completion support. */
29 class option_proposer
31 public:
32 /* Default constructor. */
33 option_proposer (): m_option_suggestions (NULL)
36 /* Default destructor. */
37 ~option_proposer ();
39 /* Helper function for driver::handle_unrecognized_options.
41 Given an unrecognized option BAD_OPT (without the leading dash),
42 locate the closest reasonable matching option (again, without the
43 leading dash), or NULL.
45 The returned string is owned by the option_proposer instance. */
46 const char *suggest_option (const char *bad_opt);
48 /* Print on stdout a list of valid options that begin with OPTION_PREFIX,
49 one per line, suitable for use by Bash completion.
51 Implementation of the "-completion=" option. */
52 void suggest_completion (const char *option_prefix);
54 /* Populate RESULTS with valid completions of options that begin
55 with OPTION_PREFIX. */
56 void get_completions (const char *option_prefix, auto_string_vec &results);
58 private:
59 /* Helper function for option_proposer::suggest_option. Populate
60 m_option_suggestions with candidate strings for misspelled options.
61 The strings will be freed by the option_proposer's dtor.
62 PREFIX is used for bash completion suggestions, otherwise
63 it's set to NULL. */
64 void build_option_suggestions (const char *prefix);
66 /* Find parameter completions for --param format with SEPARATOR.
67 Again, save the completions into results. */
68 void find_param_completions (const char separator, const char *param_prefix,
69 auto_string_vec &results);
71 private:
72 /* Cache with all suggestions. */
73 auto_string_vec *m_option_suggestions;
76 #endif /* GCC_OPT_PROPOSER_H */