GCC Middle and Back End API Reference
opts-global.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "tree-pass.h"
#include "diagnostic.h"
#include "opts.h"
#include "flags.h"
#include "langhooks.h"
#include "dbgcnt.h"
#include "debug.h"
#include "output.h"
#include "plugin.h"
#include "toplev.h"
#include "context.h"
#include "stringpool.h"
#include "attribs.h"
#include "asan.h"
#include "file-prefix-map.h"
Include dependency graph for opts-global.cc:

Typedefs

typedef const charconst_char_p
 

Functions

charwrite_langs (unsigned int mask)
 
static void complain_wrong_lang (const struct cl_decoded_option *decoded, unsigned int lang_mask)
 
static void postpone_unknown_option_warning (const char *opt)
 
void print_ignored_options (void)
 
static bool unknown_option_callback (const struct cl_decoded_option *decoded)
 
static bool lang_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(*)(void))
 
static void add_input_filename (const char *filename)
 
static void read_cmdline_options (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 init_options_once (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))
 
void handle_common_deferred_options (void)
 
void handle_deferred_dump_options (void)
 

Variables

static vec< const_char_pignored_options
 
const char ** in_fnames
 
unsigned num_in_fnames
 
static unsigned int initial_lang_mask
 
const charopt_fstack_limit_symbol_arg = NULL
 
int opt_fstack_limit_register_no = -1
 

Typedef Documentation

◆ const_char_p

Command line option handling.  Code involving global state that
   should not be shared with the driver.
   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/>.   

Function Documentation

◆ add_input_filename()

static void add_input_filename ( const char * filename)
static
Handle FILENAME from the command line.   

References ggc_alloc(), in_fnames, and num_in_fnames.

Referenced by read_cmdline_options().

◆ complain_wrong_lang()

static void complain_wrong_lang ( const struct cl_decoded_option * decoded,
unsigned int lang_mask )
static
Complain that switch DECODED does not apply to this front end (mask
LANG_MASK).   

References CL_DRIVER, cl_lang_count, cl_options, lang_hooks::complain_wrong_lang_p, error(), free(), gcc_unreachable, ggc_alloc(), NULL, option(), warning(), and write_langs().

Referenced by set_default_handlers().

◆ 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 )
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(*)(void) target_option_override_hook )
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, ggc_alloc(), 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().

◆ handle_common_deferred_options()

◆ handle_deferred_dump_options()

void handle_deferred_dump_options ( void )

◆ init_options_once()

void init_options_once ( void )
Initialize global options-related settings at start-up.   

References diagnostic_color_init(), diagnostic_urls_init(), global_dc, initial_lang_mask, lang_hooks::initialize_diagnostics, and lang_hooks::option_lang_mask.

Referenced by toplev::main().

◆ lang_handle_option()

static bool lang_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(*)(void)  )
static
Handle a front-end option; arguments and return value as for
handle_option.   

References gcc_assert, ggc_alloc(), global_dc, global_options, global_options_set, and lang_hooks::handle_option.

Referenced by set_default_handlers().

◆ postpone_unknown_option_warning()

static void postpone_unknown_option_warning ( const char * opt)
static
Buffer the unknown option described by the string OPT.  Currently,
we only complain about unknown -Wno-* options if they may have
prevented a diagnostic. Otherwise, we just ignore them.  Note that
if we do complain, it is only as a warning, not an error; passing
the compiler an unrecognized -Wno-* option should never change
whether the compilation succeeds or fails.   

References ignored_options.

Referenced by unknown_option_callback().

◆ print_ignored_options()

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

References ignored_options, inform(), and UNKNOWN_LOCATION.

Referenced by toplev::main().

◆ read_cmdline_options()

static void read_cmdline_options ( 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 )
static
Handle the vector of command line options (located at LOC), storing
the results of processing DECODED_OPTIONS and DECODED_OPTIONS_COUNT
in OPTS and OPTS_SET and using DC for diagnostic state.  LANG_MASK
contains has a single bit set representing the current language.
HANDLERS describes what functions to call for the options.   

References add_input_filename(), cl_decoded_option::arg, base_of_path(), gcc_assert, ggc_alloc(), global_options, global_options_set, i, NULL, and read_cmdline_option().

Referenced by decode_options().

◆ set_default_handlers()

◆ unknown_option_callback()

static bool unknown_option_callback ( const struct cl_decoded_option * decoded)
static
Handle an unknown option DECODED, returning true if an error should
be given.   

References CL_ERR_NEGATIVE, ggc_alloc(), and postpone_unknown_option_warning().

Referenced by set_default_handlers().

◆ write_langs()

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

References ggc_alloc(), lang_names, and MAX.

Referenced by complain_wrong_lang().

Variable Documentation

◆ ignored_options

vec<const_char_p> ignored_options
static

◆ in_fnames

const char** in_fnames
Input file names.   

Referenced by add_input_filename().

◆ initial_lang_mask

unsigned int initial_lang_mask
static
Language mask determined at initialization.   

Referenced by decode_cmdline_options_to_array_default_mask(), decode_options(), init_options_once(), and set_default_handlers().

◆ num_in_fnames

unsigned num_in_fnames
The count of input filenames.   

Referenced by add_input_filename().

◆ opt_fstack_limit_register_no

int opt_fstack_limit_register_no = -1

◆ opt_fstack_limit_symbol_arg

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

Referenced by handle_common_deferred_options(), and init_emit_regs().