GCC Middle and Back End API Reference
opts.h File Reference
#include "rich-location.h"
#include "obstack.h"
Include dependency graph for opts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cl_option
 
struct  cl_var
 
struct  cl_option_state
 
struct  cl_enum_arg
 
struct  cl_enum
 
struct  cl_decoded_option
 
struct  cl_deferred_option
 
struct  cl_option_handler_func
 
struct  cl_option_handlers
 
struct  sanitizer_opts_s
 
struct  zero_call_used_regs_opts_s
 
struct  switchstr
 

Macros

#define CL_PARAMS   (1U << 16) /* Fake entry. Used to display --param info with --help. @endverbatim */
 
#define CL_WARNING   (1U << 17) /* Enables an (optional) warning message. @endverbatim */
 
#define CL_OPTIMIZATION   (1U << 18) /* Enables an (optional) optimization. @endverbatim */
 
#define CL_DRIVER   (1U << 19) /* Driver option. @endverbatim */
 
#define CL_TARGET   (1U << 20) /* Target-specific option. @endverbatim */
 
#define CL_COMMON   (1U << 21) /* Language-independent. @endverbatim */
 
#define CL_MIN_OPTION_CLASS   CL_PARAMS
 
#define CL_MAX_OPTION_CLASS   CL_COMMON
 
#define CL_JOINED   (1U << 22) /* If takes joined argument. @endverbatim */
 
#define CL_SEPARATE   (1U << 23) /* If takes a separate argument. @endverbatim */
 
#define CL_UNDOCUMENTED   (1U << 24) /* Do not output with --help. @endverbatim */
 
#define CL_NO_DWARF_RECORD   (1U << 25) /* Do not add to producer string. @endverbatim */
 
#define CL_PCH_IGNORE   (1U << 26) /* Do compare state for pch. @endverbatim */
 
#define CL_ENUM_CANONICAL   (1 << 0) /* Canonical for this value. @endverbatim */
 
#define CL_ENUM_DRIVER_ONLY   (1 << 1) /* Only accepted in the driver. @endverbatim */
 
#define CL_ENUM_SET_SHIFT   2 /* Shift for enum set. @endverbatim */
 
#define CL_ERR_DISABLED   (1 << 0) /* Disabled in this configuration. @endverbatim */
 
#define CL_ERR_MISSING_ARG   (1 << 1) /* Argument required but missing. @endverbatim */
 
#define CL_ERR_WRONG_LANG   (1 << 2) /* Option for wrong language. @endverbatim */
 
#define CL_ERR_UINT_ARG   (1 << 3) /* Bad unsigned integer argument. @endverbatim */
 
#define CL_ERR_INT_RANGE_ARG   (1 << 4) /* Bad unsigned integer argument. @endverbatim */
 
#define CL_ERR_ENUM_ARG   (1 << 5) /* Bad enumerated argument. @endverbatim */
 
#define CL_ERR_NEGATIVE
 
#define CL_ERR_ENUM_SET_ARG   (1 << 7) /* Bad argument of enumerated set. @endverbatim */
 
#define SET_OPTION_IF_UNSET(OPTS, OPTS_SET, OPTION, VALUE)
 
#define OPTION_SET_P(OPTION)
 
#define SWITCH_LIVE   (1 << 0)
 
#define SWITCH_FALSE   (1 << 1)
 
#define SWITCH_IGNORE   (1 << 2)
 
#define SWITCH_IGNORE_PERMANENTLY   (1 << 3)
 
#define SWITCH_KEEP_FOR_GCC   (1 << 4)
 

Enumerations

enum  cl_var_type {
  CLVC_INTEGER , CLVC_EQUAL , CLVC_BIT_CLEAR , CLVC_BIT_SET ,
  CLVC_SIZE , CLVC_STRING , CLVC_ENUM , CLVC_DEFER
}
 
enum  cl_enum_var_value { CLEV_NORMAL , CLEV_SET , CLEV_BITSET }
 

Functions

const char * get_opt_url_suffix (int option_index, unsigned lang_mask)
 
char * opts_concat (const char *first,...)
 
size_t find_opt (const char *input, unsigned int lang_mask)
 
HOST_WIDE_INT integral_argument (const char *arg, int *=NULL, bool=false)
 
bool enum_value_to_arg (const struct cl_enum_arg *enum_args, const char **argp, int value, unsigned int lang_mask)
 
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)
 
void init_options_once (void)
 
void init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
 
void init_opts_obstack (void)
 
void decode_cmdline_options_to_array_default_mask (unsigned int argc, const char **argv, struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count)
 
void set_default_handlers (struct cl_option_handlers *handlers, void(*target_option_override_hook)(void))
 
void decode_options (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded_options, unsigned int decoded_options_count, location_t loc, diagnostic_context *dc, void(*target_option_override_hook)(void))
 
int option_enabled (int opt_idx, unsigned lang_mask, void *opts)
 
bool get_option_state (struct gcc_options *, int, struct cl_option_state *)
 
void set_option (struct gcc_options *opts, struct gcc_options *opts_set, size_t opt_index, HOST_WIDE_INT value, const char *arg, int kind, location_t loc, diagnostic_context *dc, HOST_WIDE_INT=0)
 
void * option_flag_var (int opt_index, struct gcc_options *opts)
 
bool handle_generated_option (struct gcc_options *opts, struct gcc_options *opts_set, size_t opt_index, const char *arg, HOST_WIDE_INT value, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, bool generated_p, diagnostic_context *dc)
 
void generate_option (size_t opt_index, const char *arg, HOST_WIDE_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 control_warning_option (unsigned int opt_index, int kind, const char *arg, 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)
 
char * write_langs (unsigned int mask)
 
void print_ignored_options (void)
 
void handle_common_deferred_options (void)
 
void handle_deferred_dump_options (void)
 
unsigned int parse_sanitizer_options (const char *, location_t, int, unsigned int, int, bool)
 
unsigned int parse_no_sanitize_attribute (char *value)
 
bool common_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, diagnostic_context *dc, void(*target_option_override_hook)(void))
 
bool target_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, diagnostic_context *dc, void(*target_option_override_hook)(void))
 
void finish_options (struct gcc_options *opts, struct gcc_options *opts_set, location_t loc)
 
void diagnose_options (gcc_options *opts, gcc_options *opts_set, location_t loc)
 
void print_help (struct gcc_options *opts, unsigned int lang_mask, const char *help_option_argument)
 
void default_options_optimization (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded_options, unsigned int decoded_options_count, location_t loc, unsigned int lang_mask, const struct cl_option_handlers *handlers, diagnostic_context *dc)
 
void set_struct_debug_option (struct gcc_options *opts, location_t loc, const char *value)
 
bool opt_enum_arg_to_value (size_t opt_index, const char *arg, int *value, unsigned int lang_mask)
 
const char * get_option_prefix_remapping (const char *p, size_t sz, const char **out_new_prefix)
 
void add_misspelling_candidates (auto_vec< char * > *candidates, const struct cl_option *option, const char *base_option)
 
const char * candidates_list_and_hint (const char *arg, char *&str, const auto_vec< const char * > &candidates)
 
bool parse_and_check_align_values (const char *flag, const char *name, auto_vec< unsigned > &result_values, bool report_error, location_t loc)
 
void parse_and_check_patch_area (const char *arg, bool report_error, HOST_WIDE_INT *patch_area_size, HOST_WIDE_INT *patch_area_start)
 
void parse_options_from_collect_gcc_options (const char *, obstack *, int *)
 
void prepend_xassembler_to_collect_as_options (const char *, obstack *)
 
char * gen_command_line_string (cl_decoded_option *options, unsigned int options_count)
 
char * gen_producer_string (const char *language_string, cl_decoded_option *options, unsigned int options_count)
 
label_text get_option_url_suffix (int option_index, unsigned lang_mask)
 

Variables

const struct cl_option cl_options []
 
const unsigned int cl_options_count
 
const char *const lang_names []
 
const unsigned int cl_lang_count
 
const struct cl_enum cl_enums []
 
const unsigned int cl_enums_count
 
const char * opt_fstack_limit_symbol_arg
 
int opt_fstack_limit_register_no
 
bool flag_stack_protector_set_by_fhardened_p
 
const char ** in_fnames
 
unsigned num_in_fnames
 
struct obstack opts_obstack
 
const struct sanitizer_opts_s sanitizer_opts []
 
const struct zero_call_used_regs_opts_s zero_call_used_regs_opts []
 
vec< const char * > help_option_arguments
 

Macro Definition Documentation

◆ CL_COMMON

◆ CL_DRIVER

◆ CL_ENUM_CANONICAL

#define CL_ENUM_CANONICAL   (1 << 0) /* Canonical for this value. @endverbatim */
Flags for an enumerated option argument.   

Referenced by enum_value_to_arg().

◆ CL_ENUM_DRIVER_ONLY

#define CL_ENUM_DRIVER_ONLY   (1 << 1) /* Only accepted in the driver. @endverbatim */

◆ CL_ENUM_SET_SHIFT

#define CL_ENUM_SET_SHIFT   2 /* Shift for enum set. @endverbatim */

◆ CL_ERR_DISABLED

#define CL_ERR_DISABLED   (1 << 0) /* Disabled in this configuration. @endverbatim */
Possible ways in which a command-line option may be erroneous.
These do not include not being known at all; an option index of
OPT_SPECIAL_unknown is used for that.   

Referenced by cmdline_handle_error(), and decode_cmdline_option().

◆ CL_ERR_ENUM_ARG

#define CL_ERR_ENUM_ARG   (1 << 5) /* Bad enumerated argument. @endverbatim */

◆ CL_ERR_ENUM_SET_ARG

#define CL_ERR_ENUM_SET_ARG   (1 << 7) /* Bad argument of enumerated set. @endverbatim */

◆ CL_ERR_INT_RANGE_ARG

#define CL_ERR_INT_RANGE_ARG   (1 << 4) /* Bad unsigned integer argument. @endverbatim */

◆ CL_ERR_MISSING_ARG

#define CL_ERR_MISSING_ARG   (1 << 1) /* Argument required but missing. @endverbatim */

◆ CL_ERR_NEGATIVE

#define CL_ERR_NEGATIVE
Value:
(1 << 6) /* Negative form of option
not permitted (together
with OPT_SPECIAL_unknown). @endverbatim */

Referenced by decode_cmdline_option(), driver_unknown_option_callback(), and unknown_option_callback().

◆ CL_ERR_UINT_ARG

#define CL_ERR_UINT_ARG   (1 << 3) /* Bad unsigned integer argument. @endverbatim */

◆ CL_ERR_WRONG_LANG

#define CL_ERR_WRONG_LANG   (1 << 2) /* Option for wrong language. @endverbatim */

◆ CL_JOINED

#define CL_JOINED   (1U << 22) /* If takes joined argument. @endverbatim */
From here on the bits describe attributes of the options.
Before this point the bits have described the class of the option.
This distinction is important because --help will not list options
which only have these higher bits set.   

Referenced by control_warning_option(), decode_cmdline_option(), enable_warning_as_error(), find_opt(), generate_canonical_option(), print_filtered_help(), print_help(), print_specific_help(), prune_options(), and remapping_prefix_p().

◆ CL_MAX_OPTION_CLASS

#define CL_MAX_OPTION_CLASS   CL_COMMON

◆ CL_MIN_OPTION_CLASS

#define CL_MIN_OPTION_CLASS   CL_PARAMS

◆ CL_NO_DWARF_RECORD

#define CL_NO_DWARF_RECORD   (1U << 25) /* Do not add to producer string. @endverbatim */

Referenced by gen_command_line_string().

◆ CL_OPTIMIZATION

#define CL_OPTIMIZATION   (1U << 18) /* Enables an (optional) optimization. @endverbatim */

◆ CL_PARAMS

#define CL_PARAMS   (1U << 16) /* Fake entry. Used to display --param info with --help. @endverbatim */

◆ CL_PCH_IGNORE

#define CL_PCH_IGNORE   (1U << 26) /* Do compare state for pch. @endverbatim */

Referenced by option_affects_pch_p().

◆ CL_SEPARATE

#define CL_SEPARATE   (1U << 23) /* If takes a separate argument. @endverbatim */

◆ CL_TARGET

◆ CL_UNDOCUMENTED

#define CL_UNDOCUMENTED   (1U << 24) /* Do not output with --help. @endverbatim */

◆ CL_WARNING

#define CL_WARNING   (1U << 17) /* Enables an (optional) warning message. @endverbatim */

◆ OPTION_SET_P

#define OPTION_SET_P ( OPTION)
Value:
global_options_set.x_ ## OPTION
#define global_options_set
Definition opts.cc:195
Return true if OPTION is set by user in global options.   

Referenced by default_max_noce_ifcvt_seq_cost(), expand_omp_simd(), lto_write_options(), oacc_xform_loop(), omp_max_vf(), process_options(), and sra_get_max_scalarization_size().

◆ SET_OPTION_IF_UNSET

#define SET_OPTION_IF_UNSET ( OPTS,
OPTS_SET,
OPTION,
VALUE )
Value:
do \
{ \
if (!(OPTS_SET)->x_ ## OPTION) \
(OPTS)->x_ ## OPTION = VALUE; \
} \
while (false)
Set OPTION in OPTS to VALUE if the option is not set in OPTS_SET.   

Referenced by common_handle_option(), default_options_optimization(), enable_fdo_optimizations(), and finish_options().

◆ SWITCH_FALSE

#define SWITCH_FALSE   (1 << 1)

Referenced by check_live_switch().

◆ SWITCH_IGNORE

#define SWITCH_IGNORE   (1 << 2)

◆ SWITCH_IGNORE_PERMANENTLY

#define SWITCH_IGNORE_PERMANENTLY   (1 << 3)

Referenced by check_live_switch(), and do_self_spec().

◆ SWITCH_KEEP_FOR_GCC

#define SWITCH_KEEP_FOR_GCC   (1 << 4)

◆ SWITCH_LIVE

#define SWITCH_LIVE   (1 << 0)
Find all the switches given to us
and make a vector describing them.
The elements of the vector are strings, one per switch given.
If a switch uses following arguments, then the `part1' field
is the switch itself and the `args' field
is a null-terminated vector containing the following arguments.
Bits in the `live_cond' field are:
SWITCH_LIVE to indicate this switch is true in a conditional spec.
SWITCH_FALSE to indicate this switch is overridden by a later switch.
SWITCH_IGNORE to indicate this switch should be ignored (used in %<S).
SWITCH_IGNORE_PERMANENTLY to indicate this switch should be ignored.
SWITCH_KEEP_FOR_GCC to indicate that this switch, otherwise ignored,
should be included in COLLECT_GCC_OPTIONS.
in all do_spec calls afterwards.  Used for %<S from self specs.
The `known' field describes whether this is an internal switch.
The `validated' field describes whether any spec has looked at this switch;
if it remains false at the end of the run, the switch must be meaningless.
The `ordering' field is used to temporarily mark switches that have to be
kept in a specific order.   

Referenced by check_live_switch().

Enumeration Type Documentation

◆ cl_enum_var_value

Values for var_value member of CLVC_ENUM.   
Enumerator
CLEV_NORMAL 
CLEV_SET 
CLEV_BITSET 

◆ cl_var_type

Command line option handling.
   Copyright (C) 2002-2024 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/>.   
Specifies how a switch's VAR_VALUE relates to its FLAG_VAR.   
Enumerator
CLVC_INTEGER 
CLVC_EQUAL 
CLVC_BIT_CLEAR 
CLVC_BIT_SET 
CLVC_SIZE 
CLVC_STRING 
CLVC_ENUM 
CLVC_DEFER 

Function Documentation

◆ add_misspelling_candidates()

void add_misspelling_candidates ( auto_vec< char * > * candidates,
const struct cl_option * option,
const char * opt_text )
extern
Helper function for gcc.cc's driver::suggest_option, for populating the
vec of suggestions for misspelled options.

option_map above provides various prefixes for spelling command-line
options, which decode_cmdline_option uses to map spellings of options
to specific options.  We want to do the reverse: to find all the ways
that a user could validly spell an option.

Given valid OPT_TEXT (with a leading dash) for OPTION, add it and all
of its valid variant spellings to CANDIDATES, each without a leading
dash.

For example, given "-Wabi-tag", the following are added to CANDIDATES:
  "Wabi-tag"
  "Wno-abi-tag"
  "-warn-abi-tag"
  "-warn-no-abi-tag".

The added strings must be freed using free.   

References candidates, gcc_assert, i, option_map::negated, option_map::new_prefix, NULL, option_map::opt0, option_map::opt1, option(), and remapping_prefix_p().

Referenced by option_proposer::build_option_suggestions().

◆ candidates_list_and_hint()

const char * candidates_list_and_hint ( const char * arg,
char *& str,
const auto_vec< const char * > & candidates )
extern
Helper function for listing valid choices and hint for misspelled
value.  CANDIDATES is a vector containing all valid strings,
STR is set to a heap allocated string that contains all those
strings concatenated, separated by spaces, and the return value
is the closest string from those to ARG, or NULL if nothing is
close enough.  Callers should XDELETEVEC (STR) after using it
to avoid memory leaks.   

References candidate(), candidates, find_closest_string(), FOR_EACH_VEC_ELT, gcc_assert, and i.

Referenced by check_offload_target_name(), and cmdline_handle_error().

◆ common_handle_option()

bool common_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,
diagnostic_context * dc,
void(* target_option_override_hook )(void) )
extern
Handle target- and language-independent options.  Return zero to
generate an "unknown option" message.  Only options that need
extra handling need to be listed here; if you simply want
DECODED->value assigned to a variable, it happens automatically.   

References add_comma_separated_to_vector(), cl_decoded_option::arg, BTF_DEBUG, CALLGRAPH_INFO_DYNAMIC_ALLOC, CALLGRAPH_INFO_NAKED, CALLGRAPH_INFO_STACK_USAGE, cl_decoded_option::canonical_option_num_elements, check_alignment_argument(), CL_DRIVER, cl_lang_count, CL_MAX_OPTION_CLASS, CL_MIN_OPTION_CLASS, CL_TARGET, CL_UNDOCUMENTED, CODEVIEW_DEBUG, control_warning_option(), CTF_DEBUG, CTFINFO_LEVEL_NONE, decode_d_option(), DEFAULT_GDB_EXTENSIONS, diagnostic_color_init(), diagnostic_output_format_init(), diagnostic_set_caret_max_width(), diagnostic_urls_init(), DINFO_LEVEL_NORMAL, DWARF2_DEBUG, enable_fdo_optimizations(), enable_warning_as_error(), diagnostic_source_printing_options::enabled, error_at(), EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1, EXTRA_DIAGNOSTIC_OUTPUT_none, flag_canon_prefix_map, free(), FULL_BUILTIN_STACK_CHECK, gcc_assert, gcc_checking_assert, GENERIC_STACK_CHECK, diagnostic_context::get_reference_printer(), handle_OPT_fdiagnostics_add_output_(), handle_OPT_fdiagnostics_set_output_(), help_option_arguments, i, diagnostic_context::m_column_origin, diagnostic_context::m_column_unit, diagnostic_context::m_fatal_errors, diagnostic_context::m_inhibit_warnings, diagnostic_context::m_pedantic_errors, diagnostic_context::m_show_column, diagnostic_context::m_source_printing, diagnostic_context::m_tabstop, diagnostic_context::m_warn_system_headers, diagnostic_source_printing_options::min_margin_width, NO_DEBUG, NO_STACK_CHECK, NULL, cl_decoded_option::opt_index, option_flag_var(), parse_and_check_patch_area(), parse_sanitizer_options(), parse_zero_call_used_regs_options(), pp_set_line_maximum_length(), print_specific_help(), SANITIZE_KERNEL_ADDRESS, SANITIZE_KERNEL_HWADDRESS, SANITIZE_RETURN, SANITIZE_UNDEFINED, SANITIZE_UNDEFINED_NONDEFAULT, SANITIZE_UNREACHABLE, set_debug_level(), diagnostic_context::set_escape_format(), diagnostic_context::set_extra_output_kind(), set_fast_math_flags(), diagnostic_context::set_max_errors(), SET_OPTION_IF_UNSET, diagnostic_context::set_path_format(), diagnostic_context::set_prefixing_rule(), diagnostic_context::set_report_bug(), diagnostic_context::set_show_cwe(), diagnostic_context::set_show_highlight_colors(), diagnostic_context::set_show_option_requested(), diagnostic_context::set_show_path_depths(), diagnostic_context::set_show_rules(), diagnostic_context::set_text_art_charset(), set_unsafe_math_optimizations_flags(), diagnostic_context::set_warning_as_error_requested(), set_Wstrict_aliasing(), diagnostic_source_printing_options::show_event_links_p, diagnostic_source_printing_options::show_labels_p, diagnostic_source_printing_options::show_line_numbers_p, STATIC_BUILTIN_STACK_CHECK, cl_decoded_option::value, VMS_DEBUG, WARN_STRICT_OVERFLOW_CONDITIONAL, and warning_at().

Referenced by set_default_handlers(), and set_option_handlers().

◆ control_warning_option()

void control_warning_option ( unsigned int opt_index,
int kind,
const char * arg,
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 )
extern
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=).  ARG is the
argument of the option for joined options, or NULL otherwise.  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_arg, cl_option::alias_target, cl_enums, CL_ERR_ENUM_ARG, CL_ERR_MISSING_ARG, CL_ERR_UINT_ARG, CL_JOINED, cl_options, CLVC_ENUM, CLVC_INTEGER, CLVC_SIZE, cmdline_handle_error(), diagnostic_classify_diagnostic(), enum_arg_to_value(), enum_value_to_arg(), error(), gcc_assert, handle_generated_option(), integral_argument(), NULL, option(), and cl_enum::values.

Referenced by common_handle_option(), and enable_warning_as_error().

◆ 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 )
extern
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(), i, cl_decoded_option::mask, NULL, cl_decoded_option::opt_index, opts_concat(), cl_decoded_option::orig_option_with_args_text, prune_options(), cl_decoded_option::value, and cl_decoded_option::warn_message.

Referenced by driver::decode_argv(), decode_cmdline_options_to_array_default_mask(), do_self_spec(), and get_options_from_collect_gcc_options().

◆ decode_cmdline_options_to_array_default_mask()

void decode_cmdline_options_to_array_default_mask ( unsigned int argc,
const char ** argv,
struct cl_decoded_option ** decoded_options,
unsigned int * decoded_options_count )
extern
Decode command-line options to an array, like
decode_cmdline_options_to_array and with the same arguments but
using the default lang_mask.   

References CL_COMMON, CL_TARGET, decode_cmdline_options_to_array(), and initial_lang_mask.

Referenced by toplev::main().

◆ decode_options()

void decode_options ( struct gcc_options * opts,
struct gcc_options * opts_set,
struct cl_decoded_option * decoded_options,
unsigned int decoded_options_count,
location_t loc,
diagnostic_context * dc,
void(* target_option_override_hook )(void) )
extern
Parse command line options and set default flag values.  Do minimal
options processing.  The decoded options are in *DECODED_OPTIONS
and *DECODED_OPTIONS_COUNT; settings go in OPTS, OPTS_SET and DC;
the options are located at LOC.   

References default_options_optimization(), finish_options(), FOR_EACH_VEC_ELT, cl_option_handlers::handlers, help_option_arguments, i, initial_lang_mask, print_help(), read_cmdline_options(), set_default_handlers(), and cl_option_handlers::target_option_override_hook.

Referenced by toplev::main().

◆ default_options_optimization()

void default_options_optimization ( struct gcc_options * opts,
struct gcc_options * opts_set,
struct cl_decoded_option * decoded_options,
unsigned int decoded_options_count,
location_t loc,
unsigned int lang_mask,
const struct cl_option_handlers * handlers,
diagnostic_context * dc )
extern
Default the options in OPTS and OPTS_SET based on the optimization
settings in DECODED_OPTIONS and DECODED_OPTIONS_COUNT.   

References cl_decoded_option::arg, default_options_table, error_at(), i, integral_argument(), maybe_default_options(), cl_decoded_option::opt_index, SET_OPTION_IF_UNSET, and cl_decoded_option::value.

Referenced by decode_options().

◆ diagnose_options()

void diagnose_options ( gcc_options * opts,
gcc_options * opts_set,
location_t loc )
extern
The function diagnoses incompatible combinations for provided options
(OPTS and OPTS_SET) at a given LOCation.  The function is called both
when command line is parsed (after the target optimization hook) and
when an optimize/target attribute (or pragma) is used.   

References inform(), UI_SJLJ, and UI_TARGET.

Referenced by finish_options(), and process_options().

◆ enum_value_to_arg()

bool enum_value_to_arg ( const struct cl_enum_arg * enum_args,
const char ** argp,
int value,
unsigned int lang_mask )
extern
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, CL_ENUM_CANONICAL, enum_arg_ok_for_language(), cl_option::flags, i, and NULL.

Referenced by control_warning_option(), decode_cmdline_option(), and print_filtered_help().

◆ find_opt()

size_t find_opt ( const char * input,
unsigned int lang_mask )
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_JOINED, cl_options, cl_options_count, comp, cl_option::flags, cl_option::opt_len, cl_option::opt_text, and remapping_prefix_p().

Referenced by decode_cmdline_option(), and enable_warning_as_error().

◆ finish_options()

◆ gen_command_line_string()

char * gen_command_line_string ( cl_decoded_option * options,
unsigned int options_count )
extern
Return a heap allocated producer with command line options.   

References CL_NO_DWARF_RECORD, cl_options, FOR_EACH_VEC_ELT, gcc_checking_assert, i, and switches.

Referenced by gen_producer_string(), init_asm_output(), and process_options().

◆ gen_producer_string()

char * gen_producer_string ( const char * language_string,
cl_decoded_option * options,
unsigned int options_count )
extern
Return a heap allocated producer string including command line options.   

References free(), gen_command_line_string(), and NULL.

Referenced by init_asm_output().

◆ generate_option()

void generate_option ( size_t opt_index,
const char * arg,
HOST_WIDE_INT value,
unsigned int lang_mask,
struct cl_decoded_option * decoded )

◆ generate_option_input_file()

◆ get_opt_url_suffix()

const char * get_opt_url_suffix ( int option_index,
unsigned lang_mask )
extern

Referenced by get_option_url_suffix().

◆ get_option_prefix_remapping()

const char * get_option_prefix_remapping ( const char * p,
size_t sz,
const char ** out_new_prefix )
extern
Given buffer P of size SZ, look for a prefix within OPTION_MAP;
if found, return the prefix and write the new prefix to *OUT_NEW_PREFIX.
Otherwise return nullptr.   

References i, option_map::new_prefix, and option_map::opt0.

◆ get_option_state()

bool get_option_state ( struct gcc_options * opts,
int option,
struct cl_option_state * state )
extern
Fill STATE with the current state of option OPTION in OPTS.  Return
true if there is some state to store.   

References cl_enums, cl_option::cl_host_wide_int, cl_options, CLVC_BIT_CLEAR, CLVC_BIT_SET, CLVC_DEFER, CLVC_ENUM, CLVC_EQUAL, CLVC_INTEGER, CLVC_SIZE, CLVC_STRING, option(), option_enabled(), option_flag_var(), cl_option::var_enum, and cl_enum::var_size.

Referenced by option_affects_pch_p().

◆ get_option_url_suffix()

label_text get_option_url_suffix ( int option_index,
unsigned lang_mask )
extern
Get the url within the documentation for this option, or NULL.   

References cl_options, get_opt_url_suffix(), get_option_html_page(), and NULL.

Referenced by gcc_diagnostic_option_manager::make_option_url().

◆ handle_common_deferred_options()

◆ handle_deferred_dump_options()

void handle_deferred_dump_options ( void )
extern

◆ handle_generated_option()

bool handle_generated_option ( struct gcc_options * opts,
struct gcc_options * opts_set,
size_t opt_index,
const char * arg,
HOST_WIDE_INT value,
unsigned int lang_mask,
int kind,
location_t loc,
const struct cl_option_handlers * handlers,
bool generated_p,
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 cl_decoded_option::arg, generate_option(), handle_option(), cl_decoded_option::opt_index, and cl_decoded_option::value.

Referenced by control_warning_option(), and maybe_default_option().

◆ init_options_once()

◆ init_options_struct()

void init_options_struct ( struct gcc_options * opts,
struct gcc_options * opts_set )
extern
Initialize OPTS and OPTS_SET before using them in parsing options.   

References gcc_assert, and opts_obstack.

Referenced by driver::decode_argv(), lto_input_ts_function_decl_tree_pointers(), and toplev::main().

◆ init_opts_obstack()

void init_opts_obstack ( void )
extern
Initialize opts_obstack.   

References gcc_obstack_init, and opts_obstack.

Referenced by driver::decode_argv(), driver_get_configure_time_options(), main(), and toplev::main().

◆ integral_argument()

HOST_WIDE_INT integral_argument ( const char * arg,
int * err,
bool byte_size_suffix )
extern
If ARG is a non-negative decimal or hexadecimal integer representable
in HOST_WIDE_INT return its value, otherwise return -1.  If ERR is not
null set *ERR to zero on success or to EINVAL or to the value of errno
otherwise.   

References end(), errno, HOST_WIDE_INT_M1U, HOST_WIDE_INT_UC, and NULL.

Referenced by control_warning_option(), decode_cmdline_option(), default_options_optimization(), parse_and_check_patch_area(), and set_debug_level().

◆ opt_enum_arg_to_value()

bool opt_enum_arg_to_value ( size_t opt_index,
const char * arg,
int * value,
unsigned int lang_mask )
extern
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(), gcc_assert, option(), and cl_enum::values.

◆ option_enabled()

int option_enabled ( int opt_idx,
unsigned lang_mask,
void * opts )
extern
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
(or if the value is unknown, typically set later in target).   

References CL_COMMON, cl_options, CLVC_BIT_CLEAR, CLVC_BIT_SET, CLVC_DEFER, CLVC_ENUM, CLVC_EQUAL, CLVC_INTEGER, CLVC_SIZE, CLVC_STRING, option(), and option_flag_var().

Referenced by get_option_state(), compiler_diagnostic_option_manager::option_enabled_p(), print_filtered_help(), and suggest_attribute().

◆ option_flag_var()

void * option_flag_var ( int opt_index,
struct gcc_options * opts )
extern
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, NULL, and option().

Referenced by common_handle_option(), get_option_state(), handle_option(), option_affects_pch_p(), option_enabled(), print_filtered_help(), and set_option().

◆ opts_concat()

char * opts_concat ( const char * first,
... )
extern
Like libiberty concat, but allocate using opts_obstack.   

References ap, end(), and opts_obstack.

Referenced by decode_cmdline_options_to_array(), finish_options(), generate_canonical_option(), and generate_option().

◆ parse_and_check_align_values()

bool parse_and_check_align_values ( const char * flag,
const char * name,
auto_vec< unsigned > & result_values,
bool report_error,
location_t loc )
extern
Parse -falign-NAME format for a FLAG value.  Return individual
parsed integer values into RESULT_VALUES array.  If REPORT_ERROR is
set, print error message at LOC location.   

References end(), error_at(), free(), i, MAX_CODE_ALIGN_VALUE, and NULL.

Referenced by check_alignment_argument(), and parse_N_M().

◆ parse_and_check_patch_area()

void parse_and_check_patch_area ( const char * arg,
bool report_error,
HOST_WIDE_INT * patch_area_size,
HOST_WIDE_INT * patch_area_start )
extern
Parse argument of -fpatchable-function-entry option ARG and store
corresponding values to PATCH_AREA_SIZE and PATCH_AREA_START.
If REPORT_ERROR is set to true, generate error for a problematic
option arguments.   

References error(), free(), integral_argument(), NULL, and USHRT_MAX.

Referenced by common_handle_option(), and process_options().

◆ parse_no_sanitize_attribute()

unsigned int parse_no_sanitize_attribute ( char * value)
Parse string values of no_sanitize attribute passed in VALUE.
Values are separated with comma.   

References sanitizer_opts_s::flag, i, sanitizer_opts_s::name, NULL, SANITIZE_UNDEFINED, SANITIZE_UNDEFINED_NONDEFAULT, sanitizer_opts, and warning().

◆ parse_options_from_collect_gcc_options()

void parse_options_from_collect_gcc_options ( const char * collect_gcc_options,
obstack * argv_obstack,
int * argc_p )
extern
Parse options in COLLECT_GCC_OPTIONS and push them on ARGV_OBSTACK.
Store number of arguments into ARGC_P.   

References fatal_error(), input_location, NULL, and startswith().

Referenced by get_options_from_collect_gcc_options(), and prepend_xassembler_to_collect_as_options().

◆ parse_sanitizer_options()

unsigned int parse_sanitizer_options ( const char * p,
location_t loc,
int scode,
unsigned int flags,
int value,
bool complain )
Parse comma separated sanitizer suboptions from P for option SCODE,
adjust previous FLAGS and return new ones.  If COMPLAIN is false,
don't issue diagnostics.   

References error_at(), sanitizer_opts_s::flag, get_closest_sanitizer_option(), i, sanitizer_opts_s::name, NULL, SANITIZE_ADDRESS, SANITIZE_KERNEL_ADDRESS, SANITIZE_LEAK, SANITIZE_RETURN, SANITIZE_SHADOW_CALL_STACK, SANITIZE_THREAD, SANITIZE_UNDEFINED, SANITIZE_UNDEFINED_NONDEFAULT, SANITIZE_UNREACHABLE, SANITIZE_USER_ADDRESS, SANITIZE_VPTR, and sanitizer_opts.

Referenced by common_handle_option().

◆ prepend_xassembler_to_collect_as_options()

void prepend_xassembler_to_collect_as_options ( const char * collect_as_options,
obstack * o )
extern
Prepend -Xassembler for each option in COLLECT_AS_OPTIONS,
and push on O.   

References i, obstack, opts_obstack, and parse_options_from_collect_gcc_options().

Referenced by lto_write_options(), and run_gcc().

◆ print_help()

void print_help ( struct gcc_options * opts,
unsigned int lang_mask,
const char * help_option_argument )
extern

◆ print_ignored_options()

void print_ignored_options ( void )
extern
Produce a warning for each option previously buffered.   

References ignored_options, inform(), and UNKNOWN_LOCATION.

Referenced by toplev::main().

◆ read_cmdline_option()

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 )
extern
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_decoded_option::arg, CL_ERR_WRONG_LANG, cl_options, cmdline_handle_error(), error_at(), cl_decoded_option::errors, gcc_assert, handle_option(), cl_decoded_option::opt_index, option(), cl_decoded_option::orig_option_with_args_text, cl_option_handlers::unknown_option_callback, cl_decoded_option::value, 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().

◆ set_default_handlers()

◆ set_option()

void set_option ( struct gcc_options * opts,
struct gcc_options * opts_set,
size_t opt_index,
HOST_WIDE_INT value,
const char * arg,
int kind,
location_t loc,
diagnostic_context * dc,
HOST_WIDE_INT mask )
extern
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_options, CLVC_BIT_CLEAR, CLVC_BIT_SET, CLVC_DEFER, CLVC_ENUM, CLVC_EQUAL, CLVC_INTEGER, CLVC_SIZE, CLVC_STRING, diagnostic_classify_diagnostic(), error_at(), cl_enum::get, INT_MAX, NULL, option(), option_flag_var(), and cl_enum::set.

Referenced by handle_option().

◆ set_struct_debug_option()

void set_struct_debug_option ( struct gcc_options * opts,
location_t loc,
const char * value )
extern

◆ target_handle_option()

bool target_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,
diagnostic_context * dc,
void(* target_option_override_hook )(void) )
extern
Handle a back-end option; arguments and return value as for
handle_option.   

References gcc_assert, and global_dc.

Referenced by set_default_handlers(), and set_option_handlers().

◆ write_langs()

char * write_langs ( unsigned int mask)
extern
Return a malloced slash-separated list of languages in MASK.   

References lang_names, and MAX.

Referenced by complain_wrong_lang().

Variable Documentation

◆ cl_enums

◆ cl_enums_count

const unsigned int cl_enums_count
extern

Referenced by print_filtered_help().

◆ cl_lang_count

const unsigned int cl_lang_count
extern

◆ cl_options

◆ cl_options_count

◆ flag_stack_protector_set_by_fhardened_p

bool flag_stack_protector_set_by_fhardened_p
extern
Set by finish_options when flag_stack_protector was set only because of
-fhardened.  Yuck.   

Referenced by finish_options(), and process_options().

◆ help_option_arguments

vec<const char *> help_option_arguments
extern
--help option argument if set.   

Referenced by common_handle_option(), and decode_options().

◆ in_fnames

const char** in_fnames
extern
Input file names.   

Referenced by add_input_filename().

◆ lang_names

const char* const lang_names[]
extern

◆ num_in_fnames

unsigned num_in_fnames
extern
The count of input filenames.   

Referenced by add_input_filename().

◆ opt_fstack_limit_register_no

int opt_fstack_limit_register_no
extern

◆ opt_fstack_limit_symbol_arg

const char* opt_fstack_limit_symbol_arg
extern
Hold command-line options associated with stack limitation.   

Referenced by handle_common_deferred_options(), and init_emit_regs().

◆ opts_obstack

◆ sanitizer_opts

const struct sanitizer_opts_s sanitizer_opts[]

◆ zero_call_used_regs_opts

const struct zero_call_used_regs_opts_s zero_call_used_regs_opts[]