GCC Middle and Back End API Reference
|
Data Structures | |
struct | option_map |
Functions | |
static void | prune_options (struct cl_decoded_option **, unsigned int *) |
size_t | find_opt () |
int | integral_argument () |
static bool | option_ok_for_language (const struct cl_option *option, unsigned int lang_mask) |
static bool | enum_arg_ok_for_language (const struct cl_enum_arg *enum_arg, unsigned int lang_mask) |
static bool | enum_arg_to_value (const struct cl_enum_arg *enum_args, const char *arg, int *value, unsigned int lang_mask) |
bool | opt_enum_arg_to_value (size_t opt_index, const char *arg, int *value, unsigned int lang_mask) |
bool | enum_value_to_arg (const struct cl_enum_arg *enum_args, const char **argp, int value, unsigned int lang_mask) |
static void | generate_canonical_option (size_t opt_index, const char *arg, int value, struct cl_decoded_option *decoded) |
static unsigned int | decode_cmdline_option (const char **argv, unsigned int lang_mask, struct cl_decoded_option *decoded) |
char * | opts_concat () |
void | decode_cmdline_options_to_array (unsigned int argc, const char **argv, unsigned int lang_mask, struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count) |
static bool | cancel_option () |
static bool | handle_option (struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, bool generated_p, diagnostic_context *dc) |
bool | handle_generated_option (struct gcc_options *opts, struct gcc_options *opts_set, size_t opt_index, const char *arg, int value, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, diagnostic_context *dc) |
void | generate_option (size_t opt_index, const char *arg, int value, unsigned int lang_mask, struct cl_decoded_option *decoded) |
void | generate_option_input_file (const char *file, struct cl_decoded_option *decoded) |
void | read_cmdline_option (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded, location_t loc, unsigned int lang_mask, const struct cl_option_handlers *handlers, diagnostic_context *dc) |
void | set_option (struct gcc_options *opts, struct gcc_options *opts_set, int opt_index, int value, const char *arg, int kind, location_t loc, diagnostic_context *dc) |
void * | option_flag_var () |
int | option_enabled () |
bool | get_option_state (struct gcc_options *opts, int option, struct cl_option_state *state) |
void | control_warning_option (unsigned int opt_index, int kind, bool imply, location_t loc, unsigned int lang_mask, const struct cl_option_handlers *handlers, struct gcc_options *opts, struct gcc_options *opts_set, diagnostic_context *dc) |
Variables | |
static struct option_map | option_map [] |
struct obstack | opts_obstack |
|
static |
Return true if NEXT_OPT_IDX cancels OPT_IDX. Return false if the next one is the same as ORIG_NEXT_OPT_IDX.
References cl_options.
Referenced by prune_options().
void control_warning_option | ( | unsigned int | opt_index, |
int | kind, | ||
bool | imply, | ||
location_t | loc, | ||
unsigned int | lang_mask, | ||
const struct cl_option_handlers * | handlers, | ||
struct gcc_options * | opts, | ||
struct gcc_options * | opts_set, | ||
diagnostic_context * | dc | ||
) |
Set a warning option OPT_INDEX (language mask LANG_MASK, option handlers HANDLERS) to have diagnostic kind KIND for option structures OPTS and OPTS_SET and diagnostic context DC (possibly NULL), at location LOC (UNKNOWN_LOCATION for -Werror=). If IMPLY, the warning option in question is implied at this point. This is used by -Werror= and #pragma GCC diagnostic.
References cl_option::alias_target, cl_options, CLVC_BOOLEAN, diagnostic_classify_diagnostic(), and handle_generated_option().
Referenced by common_handle_option(), and enable_warning_as_error().
|
static |
Decode the switch beginning at ARGV for the language indicated by LANG_MASK (including CL_COMMON and CL_TARGET if applicable), into the structure *DECODED. Returns the number of switches consumed.
References cl_option::alias_arg, cl_option::alias_target, option_map::another_char_needed, cl_decoded_option::arg, cl_decoded_option::canonical_option, cl_decoded_option::canonical_option_num_elements, cl_option::cl_disabled, cl_enums, cl_option::cl_missing_ok, cl_option::cl_negative_alias, cl_option::cl_no_driver_arg, cl_options, cl_option::cl_reject_negative, cl_option::cl_separate_alias, cl_option::cl_separate_nargs, cl_option::cl_tolower, cl_option::cl_uinteger, CLVC_ENUM, enum_arg_to_value(), enum_value_to_arg(), cl_decoded_option::errors, find_opt(), cl_option::flags, free(), generate_canonical_option(), integral_argument(), len, memcpy(), cl_option::neg_alias_arg, option_map::negated, option_map::new_prefix, option_map::opt0, option_map::opt1, cl_decoded_option::opt_index, cl_option::opt_len, option(), option_ok_for_language(), opts_obstack, cl_decoded_option::orig_option_with_args_text, strlen(), cl_decoded_option::value, cl_enum::values, cl_option::var_enum, cl_option::var_type, cl_option::warn_message, and cl_decoded_option::warn_message.
Referenced by decode_cmdline_options_to_array().
void decode_cmdline_options_to_array | ( | unsigned int | argc, |
const char ** | argv, | ||
unsigned int | lang_mask, | ||
struct cl_decoded_option ** | decoded_options, | ||
unsigned int * | decoded_options_count | ||
) |
Decode command-line options (ARGC and ARGV being the arguments of main) into an array, setting *DECODED_OPTIONS to a pointer to that array and *DECODED_OPTIONS_COUNT to the number of entries in the array. The first entry in the array is always one for the program name (OPT_SPECIAL_program_name). LANG_MASK indicates the language flags applicable for decoding (including CL_COMMON and CL_TARGET if those options should be considered applicable). Do not produce any diagnostics or set state outside of these variables.
References cl_decoded_option::arg, cl_decoded_option::canonical_option, cl_decoded_option::canonical_option_num_elements, decode_cmdline_option(), cl_decoded_option::errors, generate_option_input_file(), cl_decoded_option::opt_index, cl_decoded_option::orig_option_with_args_text, prune_options(), cl_decoded_option::value, and cl_decoded_option::warn_message.
Referenced by decode_cmdline_options_to_array_default_mask(), do_self_spec(), get_options_from_collect_gcc_options(), and main().
|
static |
Return whether ENUM_ARG is OK for the language given by LANG_MASK.
References cl_enum_arg::flags.
Referenced by enum_arg_to_value(), and enum_value_to_arg().
|
static |
Look up ARG in ENUM_ARGS for language LANG_MASK, returning true and storing the value in *VALUE if found, and returning false without modifying *VALUE if not found.
References cl_enum_arg::arg, enum_arg_ok_for_language(), and cl_enum_arg::value.
Referenced by decode_cmdline_option(), and opt_enum_arg_to_value().
bool enum_value_to_arg | ( | const struct cl_enum_arg * | enum_args, |
const char ** | argp, | ||
int | value, | ||
unsigned int | lang_mask | ||
) |
Look of VALUE in ENUM_ARGS for language LANG_MASK and store the corresponding string in *ARGP, returning true if the found string was marked as canonical, false otherwise. If VALUE is not found (which may be the case for uninitialized values if the relevant option has not been passed), set *ARGP to NULL and return false.
References cl_enum_arg::arg, enum_arg_ok_for_language(), and cl_option::flags.
Referenced by decode_cmdline_option(), and print_filtered_help().
size_t find_opt | ( | ) |
Perform a binary search to find which option the command-line INPUT matches. Returns its index in the option array, and OPT_SPECIAL_unknown on failure. This routine is quite subtle. A normal binary search is not good enough because some options can be suffixed with an argument, and multiple sub-matches can occur, e.g. input of "-pedantic" matching the initial substring of "-pedantic-errors". A more complicated example is -gstabs. It should match "-g" with an argument of "stabs". Suppose, however, that the number and list of switches are such that the binary search tests "-gen-decls" before having tested "-g". This doesn't match, and as "-gen-decls" is less than "-gstabs", it will become the lower bound of the binary search range, and "-g" will never be seen. To resolve this issue, 'optc-gen.awk' makes "-gen-decls" point, via the back_chain member, to "-g" so that failed searches that end between "-gen-decls" and the lexicographically subsequent switch know to go back and see if "-g" causes a match (which it does in this example). This search is done in such a way that the longest match for the front end in question wins. If there is no match for the current front end, the longest match for a different front end is returned (or N_OPTS if none) and the caller emits an error message.
References cl_option::back_chain, cl_options, cl_options_count, comp, cl_option::flags, cl_option::opt_len, cl_option::opt_text, and strlen().
Referenced by decode_cmdline_option(), and enable_warning_as_error().
|
static |
Fill in the canonical option part of *DECODED with an option described by OPT_INDEX, ARG and VALUE.
References cl_decoded_option::canonical_option, cl_decoded_option::canonical_option_num_elements, cl_options, cl_option::cl_reject_negative, cl_option::cl_separate_alias, cl_option::flags, memcpy(), cl_option::opt_len, cl_option::opt_text, option(), opts_concat(), and opts_obstack.
Referenced by decode_cmdline_option(), and generate_option().
void generate_option | ( | size_t | opt_index, |
const char * | arg, | ||
int | value, | ||
unsigned int | lang_mask, | ||
struct cl_decoded_option * | decoded | ||
) |
Fill in *DECODED with an option described by OPT_INDEX, ARG and VALUE for a front end using LANG_MASK. This is used when the compiler generates options internally.
References cl_decoded_option::arg, cl_decoded_option::canonical_option, cl_decoded_option::canonical_option_num_elements, cl_options, cl_decoded_option::errors, generate_canonical_option(), cl_decoded_option::opt_index, option(), option_ok_for_language(), opts_concat(), cl_decoded_option::orig_option_with_args_text, cl_decoded_option::value, and cl_decoded_option::warn_message.
Referenced by handle_generated_option().
void generate_option_input_file | ( | const char * | file, |
struct cl_decoded_option * | decoded | ||
) |
Fill in *DECODED with an option for input file FILE.
References cl_decoded_option::arg, cl_decoded_option::canonical_option, cl_decoded_option::canonical_option_num_elements, cl_decoded_option::errors, cl_decoded_option::opt_index, cl_decoded_option::orig_option_with_args_text, cl_decoded_option::value, and cl_decoded_option::warn_message.
Referenced by decode_cmdline_options_to_array().
bool get_option_state | ( | struct gcc_options * | opts, |
int | option, | ||
struct cl_option_state * | state | ||
) |
Fill STATE with the current state of option OPTION in OPTS. Return true if there is some state to store.
References cl_option_state::ch, cl_enums, cl_option::cl_host_wide_int, cl_options, CLVC_BIT_CLEAR, CLVC_BIT_SET, CLVC_BOOLEAN, CLVC_DEFER, CLVC_ENUM, CLVC_EQUAL, CLVC_STRING, cl_option_state::data, HOST_WIDE_INT, option(), option_enabled(), option_flag_var(), cl_option_state::size, strlen(), cl_option::var_enum, and cl_enum::var_size.
Referenced by option_affects_pch_p().
bool handle_generated_option | ( | struct gcc_options * | opts, |
struct gcc_options * | opts_set, | ||
size_t | opt_index, | ||
const char * | arg, | ||
int | value, | ||
unsigned int | lang_mask, | ||
int | kind, | ||
location_t | loc, | ||
const struct cl_option_handlers * | handlers, | ||
diagnostic_context * | dc | ||
) |
Like handle_option, but OPT_INDEX, ARG and VALUE describe the option instead of DECODED. This is used for callbacks when one option implies another instead of an option being decoded from the command line.
References generate_option(), and handle_option().
Referenced by control_warning_option(), and maybe_default_option().
|
static |
Handle option DECODED for the language indicated by LANG_MASK, using the handlers in HANDLERS and setting fields in OPTS and OPTS_SET. KIND is the diagnostic_t if this is a diagnostics option, DK_UNSPECIFIED otherwise, and LOC is the location of the option for options from the source file, UNKNOWN_LOCATION otherwise. GENERATED_P is true for an option generated as part of processing another option or otherwise generated internally, false for one explicitly passed by the user. Returns false if the switch was invalid. DC is the diagnostic context for options affecting diagnostics state, or NULL.
References cl_decoded_option::arg, cl_options, cl_option::flags, cl_option_handler_func::handler, cl_option_handlers::handlers, cl_option_handler_func::mask, cl_option_handlers::num_handlers, cl_decoded_option::opt_index, option(), option_flag_var(), set_option(), and cl_decoded_option::value.
Referenced by handle_generated_option(), and read_cmdline_option().
int integral_argument | ( | ) |
If ARG is a non-negative integer made up solely of digits, return its value, otherwise return -1.
Referenced by decode_cmdline_option(), default_options_optimization(), handle_param(), and set_debug_level().
bool opt_enum_arg_to_value | ( | size_t | opt_index, |
const char * | arg, | ||
int * | value, | ||
unsigned int | lang_mask | ||
) |
Look up ARG in the enum used by option OPT_INDEX for language LANG_MASK, returning true and storing the value in *VALUE if found, and returning false without modifying *VALUE if not found.
References cl_enums, cl_options, CLVC_ENUM, enum_arg_to_value(), option(), cl_enum::values, cl_option::var_enum, and cl_option::var_type.
int option_enabled | ( | ) |
Return 1 if option OPT_IDX is enabled in OPTS, 0 if it is disabled, or -1 if it isn't a simple on-off switch.
References cl_option::cl_host_wide_int, cl_options, CLVC_BIT_CLEAR, CLVC_BIT_SET, CLVC_BOOLEAN, CLVC_DEFER, CLVC_ENUM, CLVC_EQUAL, CLVC_STRING, HOST_WIDE_INT, option(), option_flag_var(), cl_option::var_type, and cl_option::var_value.
Referenced by general_init(), get_option_state(), print_filtered_help(), print_switch_values(), and suggest_attribute().
void* option_flag_var | ( | ) |
Return the address of the flag variable for option OPT_INDEX in options structure OPTS, or NULL if there is no flag variable.
References cl_options, cl_option::flag_var_offset, and option().
Referenced by common_handle_option(), get_option_state(), handle_option(), option_affects_pch_p(), option_enabled(), print_filtered_help(), and set_option().
|
static |
Return whether OPTION is OK for the language given by LANG_MASK.
References cl_option::flags.
Referenced by decode_cmdline_option(), and generate_option().
char* opts_concat | ( | ) |
Like libiberty concat, but allocate using opts_obstack.
References memcpy(), opts_obstack, and strlen().
Referenced by finish_options(), generate_canonical_option(), and generate_option().
|
static |
@verbatim Command line option handling.
Copyright (C) 2006-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
Filter out options canceled by the ones after them.
References cancel_option(), cl_options, cl_options_count, cl_option::flags, free(), cl_option::neg_index, cl_decoded_option::opt_index, and option().
Referenced by decode_cmdline_options_to_array().
void read_cmdline_option | ( | struct gcc_options * | opts, |
struct gcc_options * | opts_set, | ||
struct cl_decoded_option * | decoded, | ||
location_t | loc, | ||
unsigned int | lang_mask, | ||
const struct cl_option_handlers * | handlers, | ||
diagnostic_context * | dc | ||
) |
Handle the switch DECODED (location LOC) for the language indicated by LANG_MASK, using the handlers in *HANDLERS and setting fields in OPTS and OPTS_SET and using diagnostic context DC (if not NULL) for diagnostic options.
References cl_enum_arg::arg, cl_decoded_option::arg, cl_enums, cl_options, error_at(), cl_decoded_option::errors, handle_option(), inform(), len, memcpy(), cl_option::missing_argument_error, cl_decoded_option::opt_index, cl_option::opt_text, option(), cl_decoded_option::orig_option_with_args_text, strlen(), cl_enum::unknown_error, cl_option_handlers::unknown_option_callback, cl_enum::values, cl_option::var_enum, cl_decoded_option::warn_message, warning_at(), and cl_option_handlers::wrong_lang_callback.
Referenced by do_self_spec(), process_command(), and read_cmdline_options().
void set_option | ( | struct gcc_options * | opts, |
struct gcc_options * | opts_set, | ||
int | opt_index, | ||
int | value, | ||
const char * | arg, | ||
int | kind, | ||
location_t | loc, | ||
diagnostic_context * | dc | ||
) |
Set any field in OPTS, and OPTS_SET if not NULL, for option OPT_INDEX according to VALUE and ARG, diagnostic kind KIND, location LOC, using diagnostic context DC if not NULL for diagnostic classification.
References cl_enums, cl_option::cl_host_wide_int, cl_options, CLVC_BIT_CLEAR, CLVC_BIT_SET, CLVC_BOOLEAN, CLVC_DEFER, CLVC_ENUM, CLVC_EQUAL, CLVC_STRING, diagnostic_classify_diagnostic(), HOST_WIDE_INT, option(), option_flag_var(), cl_enum::set, cl_option::var_enum, cl_option::var_type, and cl_option::var_value.
Referenced by handle_option().
|
static |
struct obstack opts_obstack |
Obstack for option strings.
Referenced by decode_cmdline_option(), finish_options(), generate_canonical_option(), init_options_struct(), main(), and opts_concat().