summaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-24 00:51:48 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-24 00:51:48 +0000
commit7939616918aae0c21c6b6e415cbae13f7db1a1ae (patch)
treee78bd9fc9f3b4e8df779c5d10ba572a064b6c4cf /gcc/opts-common.c
parent653d3aa04002bb2bcf00b2c5b5285275661d80cd (diff)
downloadgcc-7939616918aae0c21c6b6e415cbae13f7db1a1ae.tar.gz
* flag-types.h (struct visibility_flags): Don't declare here.
* flags.h (strip_off_ending, fast_math_flags_set_p, fast_math_flags_struct_set_p): Declare here. (visibility_options): Don't declare here. * opts-common.c (option_enabled, get_option_state): Move from opts.c. * opts-global.c: Include diagnostic.h instead of diagnostic-core.h. Include tree.h, langhooks.h, lto-streamer.h and toplev.h. (const_char_p, ignored_options, in_fnames, num_in_fnames, write_langs, complain_wrong_lang, postpone_unknown_option_warning, print_ignored_options, unknown_option_callback, post_handling_callback, lang_handle_option, add_input_filename, read_cmdline_options, initial_lang_mask, init_options_once, decode_cmdline_options_to_array_default_mask, set_default_handlers, decode_options): Move from opts.c. (print_ignored_options): Use warning_at instead of saving and restoring input_location. * opts.c: Include <signal.h> and <sys/resource.h>. Include rtl.h instead of expr.h. Don't include langhooks.h, except.h or lto-streamer.h. Add more comments on includes. (strip_off_ending, setup_core_dumping, decode_d_option): Move from toplev.c. (visibility_options): Move to c-family/c-common.c. (const_char_p, ignored_options, in_fnames, num_in_fnames, write_langs, complain_wrong_lang, postpone_unknown_option_warning, print_ignored_options, unknown_option_callback, post_handling_callback, lang_handle_option, add_input_filename, read_cmdline_options, initial_lang_mask, init_options_once, decode_cmdline_options_to_array_default_mask, set_default_handlers, decode_options): Move to opts-global.c. (target_handle_option, default_options_optimization, finish_options, common_handle_option): Remove static. (option_enabled, get_option_state): Move to opts-common.c. * opts.h (common_handle_option, target_handle_option, finish_options, default_options_optimization): Declare. * toplev.c: Don't include <signal.h> or <sys/resource.h>. (setup_core_dumping, strip_off_ending, decode_d_option): Move to opts.c. * toplev.h (strip_off_ending, decode_d_option, fast_math_flags_set_p, fast_math_flags_struct_set_p): Don't declare here. * Makefile.in (opts.o, opts-global.o): Update dependencies. c-family: * c-common.c (visibility_options): Move from ../opts.c. * c-common.h (struct visibility_flags, visibility_options): Declare here. * c-opts.c (finish_options): Rename to c_finish_options. (c_common_init): Update call to finish_options. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167105 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 79d3f052bac..9a574024d37 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -994,6 +994,78 @@ option_flag_var (int opt_index, struct gcc_options *opts)
return (void *)(((char *) opts) + option->flag_var_offset);
}
+/* 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. */
+
+int
+option_enabled (int opt_idx, void *opts)
+{
+ const struct cl_option *option = &(cl_options[opt_idx]);
+ struct gcc_options *optsg = (struct gcc_options *) opts;
+ void *flag_var = option_flag_var (opt_idx, optsg);
+
+ if (flag_var)
+ switch (option->var_type)
+ {
+ case CLVC_BOOLEAN:
+ return *(int *) flag_var != 0;
+
+ case CLVC_EQUAL:
+ return *(int *) flag_var == option->var_value;
+
+ case CLVC_BIT_CLEAR:
+ return (*(int *) flag_var & option->var_value) == 0;
+
+ case CLVC_BIT_SET:
+ return (*(int *) flag_var & option->var_value) != 0;
+
+ case CLVC_STRING:
+ case CLVC_DEFER:
+ break;
+ }
+ return -1;
+}
+
+/* Fill STATE with the current state of option OPTION in OPTS. Return
+ true if there is some state to store. */
+
+bool
+get_option_state (struct gcc_options *opts, int option,
+ struct cl_option_state *state)
+{
+ void *flag_var = option_flag_var (option, opts);
+
+ if (flag_var == 0)
+ return false;
+
+ switch (cl_options[option].var_type)
+ {
+ case CLVC_BOOLEAN:
+ case CLVC_EQUAL:
+ state->data = flag_var;
+ state->size = sizeof (int);
+ break;
+
+ case CLVC_BIT_CLEAR:
+ case CLVC_BIT_SET:
+ state->ch = option_enabled (option, opts);
+ state->data = &state->ch;
+ state->size = 1;
+ break;
+
+ case CLVC_STRING:
+ state->data = *(const char **) flag_var;
+ if (state->data == 0)
+ state->data = "";
+ state->size = strlen ((const char *) state->data) + 1;
+ break;
+
+ case CLVC_DEFER:
+ return false;
+ }
+ return true;
+}
+
/* 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