comparison gcc/opts.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Command line option handling. 1 /* Command line option handling.
2 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 2 Copyright (C) 2002-2017 Free Software Foundation, Inc.
3 Free Software Foundation, Inc.
4 3
5 This file is part of GCC. 4 This file is part of GCC.
6 5
7 GCC is free software; you can redistribute it and/or modify it under 6 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 7 the terms of the GNU General Public License as published by the Free
19 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
20 19
21 #ifndef GCC_OPTS_H 20 #ifndef GCC_OPTS_H
22 #define GCC_OPTS_H 21 #define GCC_OPTS_H
23 22
24 #include "input.h" 23 #include "obstack.h"
25 #include "vec.h"
26 24
27 /* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR. */ 25 /* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR. */
28 enum cl_var_type { 26 enum cl_var_type {
29 /* The switch is enabled when FLAG_VAR is nonzero. */ 27 /* The switch is enabled when FLAG_VAR is nonzero. */
30 CLVC_BOOLEAN, 28 CLVC_BOOLEAN,
51 CLVC_DEFER 49 CLVC_DEFER
52 }; 50 };
53 51
54 struct cl_option 52 struct cl_option
55 { 53 {
54 /* Text of the option, including initial '-'. */
56 const char *opt_text; 55 const char *opt_text;
56 /* Help text for --help, or NULL. */
57 const char *help; 57 const char *help;
58 /* Error message for missing argument, or NULL. */
58 const char *missing_argument_error; 59 const char *missing_argument_error;
60 /* Warning to give when this option is used, or NULL. */
59 const char *warn_message; 61 const char *warn_message;
62 /* Argument of alias target when positive option given, or NULL. */
60 const char *alias_arg; 63 const char *alias_arg;
64 /* Argument of alias target when negative option given, or NULL. */
61 const char *neg_alias_arg; 65 const char *neg_alias_arg;
66 /* Alias target, or N_OPTS if not an alias. */
62 unsigned short alias_target; 67 unsigned short alias_target;
68 /* Previous option that is an initial substring of this one, or
69 N_OPTS if none. */
63 unsigned short back_chain; 70 unsigned short back_chain;
71 /* Option length, not including initial '-'. */
64 unsigned char opt_len; 72 unsigned char opt_len;
73 /* Next option in a sequence marked with Negative, or -1 if none. */
65 int neg_index; 74 int neg_index;
75 /* CL_* flags for this option. */
66 unsigned int flags; 76 unsigned int flags;
77 /* Disabled in this configuration. */
78 BOOL_BITFIELD cl_disabled : 1;
79 /* Options marked with CL_SEPARATE take a number of separate
80 arguments (1 to 4) that is one more than the number in this
81 bit-field. */
82 unsigned int cl_separate_nargs : 2;
83 /* Option is an alias when used with separate argument. */
84 BOOL_BITFIELD cl_separate_alias : 1;
85 /* Alias to negative form of option. */
86 BOOL_BITFIELD cl_negative_alias : 1;
87 /* Option takes no argument in the driver. */
88 BOOL_BITFIELD cl_no_driver_arg : 1;
89 /* Reject this option in the driver. */
90 BOOL_BITFIELD cl_reject_driver : 1;
91 /* Reject no- form. */
92 BOOL_BITFIELD cl_reject_negative : 1;
93 /* Missing argument OK (joined). */
94 BOOL_BITFIELD cl_missing_ok : 1;
95 /* Argument is an integer >=0. */
96 BOOL_BITFIELD cl_uinteger : 1;
97 /* Argument is a HOST_WIDE_INT. */
98 BOOL_BITFIELD cl_host_wide_int : 1;
99 /* Argument should be converted to lowercase. */
100 BOOL_BITFIELD cl_tolower : 1;
101 /* Report argument with -fverbose-asm */
102 BOOL_BITFIELD cl_report : 1;
103 /* Offset of field for this option in struct gcc_options, or
104 (unsigned short) -1 if none. */
67 unsigned short flag_var_offset; 105 unsigned short flag_var_offset;
106 /* Index in cl_enums of enum used for this option's arguments, for
107 CLVC_ENUM options. */
68 unsigned short var_enum; 108 unsigned short var_enum;
109 /* How this option's value is determined and sets a field. */
69 enum cl_var_type var_type; 110 enum cl_var_type var_type;
70 int var_value; 111 /* Value or bit-mask with which to set a field. */
112 HOST_WIDE_INT var_value;
113 /* Range info minimum, or -1. */
114 int range_min;
115 /* Range info maximum, or -1. */
116 int range_max;
71 }; 117 };
72 118
73 /* Records that the state of an option consists of SIZE bytes starting 119 /* Records that the state of an option consists of SIZE bytes starting
74 at DATA. DATA might point to CH in some cases. */ 120 at DATA. DATA might point to CH in some cases. */
75 struct cl_option_state { 121 struct cl_option_state {
81 extern const struct cl_option cl_options[]; 127 extern const struct cl_option cl_options[];
82 extern const unsigned int cl_options_count; 128 extern const unsigned int cl_options_count;
83 extern const char *const lang_names[]; 129 extern const char *const lang_names[];
84 extern const unsigned int cl_lang_count; 130 extern const unsigned int cl_lang_count;
85 131
86 #define CL_PARAMS (1 << 11) /* Fake entry. Used to display --param info with --help. */ 132 #define CL_PARAMS (1U << 16) /* Fake entry. Used to display --param info with --help. */
87 #define CL_WARNING (1 << 12) /* Enables an (optional) warning message. */ 133 #define CL_WARNING (1U << 17) /* Enables an (optional) warning message. */
88 #define CL_OPTIMIZATION (1 << 13) /* Enables an (optional) optimization. */ 134 #define CL_OPTIMIZATION (1U << 18) /* Enables an (optional) optimization. */
89 #define CL_DRIVER (1 << 14) /* Driver option. */ 135 #define CL_DRIVER (1U << 19) /* Driver option. */
90 #define CL_TARGET (1 << 15) /* Target-specific option. */ 136 #define CL_TARGET (1U << 20) /* Target-specific option. */
91 #define CL_COMMON (1 << 16) /* Language-independent. */ 137 #define CL_COMMON (1U << 21) /* Language-independent. */
92 138
93 #define CL_MIN_OPTION_CLASS CL_PARAMS 139 #define CL_MIN_OPTION_CLASS CL_PARAMS
94 #define CL_MAX_OPTION_CLASS CL_COMMON 140 #define CL_MAX_OPTION_CLASS CL_COMMON
95 141
96 /* From here on the bits describe attributes of the options. 142 /* From here on the bits describe attributes of the options.
97 Before this point the bits have described the class of the option. 143 Before this point the bits have described the class of the option.
98 This distinction is important because --help will not list options 144 This distinction is important because --help will not list options
99 which only have these higher bits set. */ 145 which only have these higher bits set. */
100 146
101 /* Options marked with CL_SEPARATE take a number of separate arguments 147 #define CL_JOINED (1U << 22) /* If takes joined argument. */
102 (1 to 4) that is one more than the number in this bit-field. */ 148 #define CL_SEPARATE (1U << 23) /* If takes a separate argument. */
103 #define CL_SEPARATE_NARGS_SHIFT 17 149 #define CL_UNDOCUMENTED (1U << 24) /* Do not output with --help. */
104 #define CL_SEPARATE_NARGS_MASK (3 << CL_SEPARATE_NARGS_SHIFT) 150 #define CL_NO_DWARF_RECORD (1U << 25) /* Do not add to producer string. */
105 151 #define CL_PCH_IGNORE (1U << 26) /* Do compare state for pch. */
106 #define CL_SEPARATE_ALIAS (1 << 19) /* Option is an alias when used with separate argument. */
107 #define CL_NO_DRIVER_ARG (1 << 20) /* Option takes no argument in the driver. */
108 #define CL_REJECT_DRIVER (1 << 21) /* Reject this option in the driver. */
109 #define CL_SAVE (1 << 22) /* Target-specific option for attribute. */
110 #define CL_DISABLED (1 << 23) /* Disabled in this configuration. */
111 #define CL_REPORT (1 << 24) /* Report argument with -fverbose-asm */
112 #define CL_JOINED (1 << 25) /* If takes joined argument. */
113 #define CL_SEPARATE (1 << 26) /* If takes a separate argument. */
114 #define CL_REJECT_NEGATIVE (1 << 27) /* Reject no- form. */
115 #define CL_MISSING_OK (1 << 28) /* Missing argument OK (joined). */
116 #define CL_UINTEGER (1 << 29) /* Argument is an integer >=0. */
117 #define CL_UNDOCUMENTED (1 << 30) /* Do not output with --help. */
118 152
119 /* Flags for an enumerated option argument. */ 153 /* Flags for an enumerated option argument. */
120 #define CL_ENUM_CANONICAL (1 << 0) /* Canonical for this value. */ 154 #define CL_ENUM_CANONICAL (1 << 0) /* Canonical for this value. */
121 #define CL_ENUM_DRIVER_ONLY (1 << 1) /* Only accepted in the driver. */ 155 #define CL_ENUM_DRIVER_ONLY (1 << 1) /* Only accepted in the driver. */
122 156
168 202
169 #define CL_ERR_DISABLED (1 << 0) /* Disabled in this configuration. */ 203 #define CL_ERR_DISABLED (1 << 0) /* Disabled in this configuration. */
170 #define CL_ERR_MISSING_ARG (1 << 1) /* Argument required but missing. */ 204 #define CL_ERR_MISSING_ARG (1 << 1) /* Argument required but missing. */
171 #define CL_ERR_WRONG_LANG (1 << 2) /* Option for wrong language. */ 205 #define CL_ERR_WRONG_LANG (1 << 2) /* Option for wrong language. */
172 #define CL_ERR_UINT_ARG (1 << 3) /* Bad unsigned integer argument. */ 206 #define CL_ERR_UINT_ARG (1 << 3) /* Bad unsigned integer argument. */
173 #define CL_ERR_ENUM_ARG (1 << 4) /* Bad enumerated argument. */ 207 #define CL_ERR_INT_RANGE_ARG (1 << 4) /* Bad unsigned integer argument. */
174 #define CL_ERR_NEGATIVE (1 << 5) /* Negative form of option 208 #define CL_ERR_ENUM_ARG (1 << 5) /* Bad enumerated argument. */
209 #define CL_ERR_NEGATIVE (1 << 6) /* Negative form of option
175 not permitted (together 210 not permitted (together
176 with OPT_SPECIAL_unknown). */ 211 with OPT_SPECIAL_unknown). */
177 212
178 /* Structure describing the result of decoding an option. */ 213 /* Structure describing the result of decoding an option. */
179 214
216 }; 251 };
217 252
218 /* Structure describing an option deferred for handling after the main 253 /* Structure describing an option deferred for handling after the main
219 option handlers. */ 254 option handlers. */
220 255
221 typedef struct 256 struct cl_deferred_option
222 { 257 {
223 /* Elements from struct cl_decoded_option used for deferred 258 /* Elements from struct cl_decoded_option used for deferred
224 options. */ 259 options. */
225 size_t opt_index; 260 size_t opt_index;
226 const char *arg; 261 const char *arg;
227 int value; 262 int value;
228 } cl_deferred_option; 263 };
229 DEF_VEC_O(cl_deferred_option);
230 DEF_VEC_ALLOC_O(cl_deferred_option,heap);
231 264
232 /* Structure describing a single option-handling callback. */ 265 /* Structure describing a single option-handling callback. */
233 266
234 struct cl_option_handler_func 267 struct cl_option_handler_func
235 { 268 {
237 bool (*handler) (struct gcc_options *opts, 270 bool (*handler) (struct gcc_options *opts,
238 struct gcc_options *opts_set, 271 struct gcc_options *opts_set,
239 const struct cl_decoded_option *decoded, 272 const struct cl_decoded_option *decoded,
240 unsigned int lang_mask, int kind, location_t loc, 273 unsigned int lang_mask, int kind, location_t loc,
241 const struct cl_option_handlers *handlers, 274 const struct cl_option_handlers *handlers,
242 diagnostic_context *dc); 275 diagnostic_context *dc,
276 void (*target_option_override_hook) (void));
243 277
244 /* The mask that must have some bit in common with the flags for the 278 /* The mask that must have some bit in common with the flags for the
245 option for this particular handler to be used. */ 279 option for this particular handler to be used. */
246 unsigned int mask; 280 unsigned int mask;
247 }; 281 };
259 /* Callback to handle, and possibly diagnose, an option for another 293 /* Callback to handle, and possibly diagnose, an option for another
260 language. */ 294 language. */
261 void (*wrong_lang_callback) (const struct cl_decoded_option *decoded, 295 void (*wrong_lang_callback) (const struct cl_decoded_option *decoded,
262 unsigned int lang_mask); 296 unsigned int lang_mask);
263 297
264 /* Callback to call after the successful handling of any option. */ 298 /* Target option override hook. */
265 void (*post_handling_callback) (const struct cl_decoded_option *decoded, 299 void (*target_option_override_hook) (void);
266 unsigned int mask);
267 300
268 /* The number of individual handlers. */ 301 /* The number of individual handlers. */
269 size_t num_handlers; 302 size_t num_handlers;
270 303
271 /* The handlers themselves. */ 304 /* The handlers themselves. */
272 struct cl_option_handler_func handlers[3]; 305 struct cl_option_handler_func handlers[3];
273 }; 306 };
274 307
308 /* Hold command-line options associated with stack limitation. */
309 extern const char *opt_fstack_limit_symbol_arg;
310 extern int opt_fstack_limit_register_no;
311
275 /* Input file names. */ 312 /* Input file names. */
276 313
277 extern const char **in_fnames; 314 extern const char **in_fnames;
278 315
279 /* The count of input filenames. */ 316 /* The count of input filenames. */
280 317
281 extern unsigned num_in_fnames; 318 extern unsigned num_in_fnames;
282 319
283 size_t find_opt (const char *input, int lang_mask); 320 extern char *opts_concat (const char *first, ...);
321
322 /* Obstack for option strings. */
323
324 extern struct obstack opts_obstack;
325
326 size_t find_opt (const char *input, unsigned int lang_mask);
284 extern int integral_argument (const char *arg); 327 extern int integral_argument (const char *arg);
285 extern bool enum_value_to_arg (const struct cl_enum_arg *enum_args, 328 extern bool enum_value_to_arg (const struct cl_enum_arg *enum_args,
286 const char **argp, int value, 329 const char **argp, int value,
287 unsigned int lang_mask); 330 unsigned int lang_mask);
288 extern void decode_cmdline_options_to_array (unsigned int argc, 331 extern void decode_cmdline_options_to_array (unsigned int argc,
291 struct cl_decoded_option **decoded_options, 334 struct cl_decoded_option **decoded_options,
292 unsigned int *decoded_options_count); 335 unsigned int *decoded_options_count);
293 extern void init_options_once (void); 336 extern void init_options_once (void);
294 extern void init_options_struct (struct gcc_options *opts, 337 extern void init_options_struct (struct gcc_options *opts,
295 struct gcc_options *opts_set); 338 struct gcc_options *opts_set);
339 extern void init_opts_obstack (void);
340 extern void finalize_options_struct (struct gcc_options *opts);
296 extern void decode_cmdline_options_to_array_default_mask (unsigned int argc, 341 extern void decode_cmdline_options_to_array_default_mask (unsigned int argc,
297 const char **argv, 342 const char **argv,
298 struct cl_decoded_option **decoded_options, 343 struct cl_decoded_option **decoded_options,
299 unsigned int *decoded_options_count); 344 unsigned int *decoded_options_count);
300 extern void set_default_handlers (struct cl_option_handlers *handlers); 345 extern void set_default_handlers (struct cl_option_handlers *handlers,
346 void (*target_option_override_hook) (void));
301 extern void decode_options (struct gcc_options *opts, 347 extern void decode_options (struct gcc_options *opts,
302 struct gcc_options *opts_set, 348 struct gcc_options *opts_set,
303 struct cl_decoded_option *decoded_options, 349 struct cl_decoded_option *decoded_options,
304 unsigned int decoded_options_count, 350 unsigned int decoded_options_count,
305 location_t loc, 351 location_t loc,
306 diagnostic_context *dc); 352 diagnostic_context *dc,
353 void (*target_option_override_hook) (void));
307 extern int option_enabled (int opt_idx, void *opts); 354 extern int option_enabled (int opt_idx, void *opts);
308 extern bool get_option_state (struct gcc_options *, int, 355 extern bool get_option_state (struct gcc_options *, int,
309 struct cl_option_state *); 356 struct cl_option_state *);
310 extern void set_option (struct gcc_options *opts, 357 extern void set_option (struct gcc_options *opts,
311 struct gcc_options *opts_set, 358 struct gcc_options *opts_set,
315 bool handle_generated_option (struct gcc_options *opts, 362 bool handle_generated_option (struct gcc_options *opts,
316 struct gcc_options *opts_set, 363 struct gcc_options *opts_set,
317 size_t opt_index, const char *arg, int value, 364 size_t opt_index, const char *arg, int value,
318 unsigned int lang_mask, int kind, location_t loc, 365 unsigned int lang_mask, int kind, location_t loc,
319 const struct cl_option_handlers *handlers, 366 const struct cl_option_handlers *handlers,
320 diagnostic_context *dc); 367 bool generated_p, diagnostic_context *dc);
321 void generate_option (size_t opt_index, const char *arg, int value, 368 void generate_option (size_t opt_index, const char *arg, int value,
322 unsigned int lang_mask, 369 unsigned int lang_mask,
323 struct cl_decoded_option *decoded); 370 struct cl_decoded_option *decoded);
324 void generate_option_input_file (const char *file, 371 void generate_option_input_file (const char *file,
325 struct cl_decoded_option *decoded); 372 struct cl_decoded_option *decoded);
329 location_t loc, 376 location_t loc,
330 unsigned int lang_mask, 377 unsigned int lang_mask,
331 const struct cl_option_handlers *handlers, 378 const struct cl_option_handlers *handlers,
332 diagnostic_context *dc); 379 diagnostic_context *dc);
333 extern void control_warning_option (unsigned int opt_index, int kind, 380 extern void control_warning_option (unsigned int opt_index, int kind,
334 bool imply, location_t loc, 381 const char *arg, bool imply, location_t loc,
335 unsigned int lang_mask, 382 unsigned int lang_mask,
336 const struct cl_option_handlers *handlers, 383 const struct cl_option_handlers *handlers,
337 struct gcc_options *opts, 384 struct gcc_options *opts,
338 struct gcc_options *opts_set, 385 struct gcc_options *opts_set,
339 diagnostic_context *dc); 386 diagnostic_context *dc);
387 extern char *write_langs (unsigned int mask);
340 extern void print_ignored_options (void); 388 extern void print_ignored_options (void);
341 extern void handle_common_deferred_options (void); 389 extern void handle_common_deferred_options (void);
390 unsigned int parse_sanitizer_options (const char *, location_t, int,
391 unsigned int, int, bool);
392
393 unsigned int parse_no_sanitize_attribute (char *value);
342 extern bool common_handle_option (struct gcc_options *opts, 394 extern bool common_handle_option (struct gcc_options *opts,
343 struct gcc_options *opts_set, 395 struct gcc_options *opts_set,
344 const struct cl_decoded_option *decoded, 396 const struct cl_decoded_option *decoded,
345 unsigned int lang_mask, int kind, 397 unsigned int lang_mask, int kind,
346 location_t loc, 398 location_t loc,
347 const struct cl_option_handlers *handlers, 399 const struct cl_option_handlers *handlers,
348 diagnostic_context *dc); 400 diagnostic_context *dc,
401 void (*target_option_override_hook) (void));
349 extern bool target_handle_option (struct gcc_options *opts, 402 extern bool target_handle_option (struct gcc_options *opts,
350 struct gcc_options *opts_set, 403 struct gcc_options *opts_set,
351 const struct cl_decoded_option *decoded, 404 const struct cl_decoded_option *decoded,
352 unsigned int lang_mask, int kind, 405 unsigned int lang_mask, int kind,
353 location_t loc, 406 location_t loc,
354 const struct cl_option_handlers *handlers, 407 const struct cl_option_handlers *handlers,
355 diagnostic_context *dc); 408 diagnostic_context *dc,
409 void (*target_option_override_hook) (void));
356 extern void finish_options (struct gcc_options *opts, 410 extern void finish_options (struct gcc_options *opts,
357 struct gcc_options *opts_set, 411 struct gcc_options *opts_set,
358 location_t loc); 412 location_t loc);
359 extern void default_options_optimization (struct gcc_options *opts, 413 extern void default_options_optimization (struct gcc_options *opts,
360 struct gcc_options *opts_set, 414 struct gcc_options *opts_set,
365 const struct cl_option_handlers *handlers, 419 const struct cl_option_handlers *handlers,
366 diagnostic_context *dc); 420 diagnostic_context *dc);
367 extern void set_struct_debug_option (struct gcc_options *opts, 421 extern void set_struct_debug_option (struct gcc_options *opts,
368 location_t loc, 422 location_t loc,
369 const char *value); 423 const char *value);
424 extern bool opt_enum_arg_to_value (size_t opt_index, const char *arg,
425 int *value, unsigned int lang_mask);
426
427 extern const struct sanitizer_opts_s
428 {
429 const char *const name;
430 unsigned int flag;
431 size_t len;
432 bool can_recover;
433 } sanitizer_opts[];
434
435 extern void add_misspelling_candidates (auto_vec<char *> *candidates,
436 const struct cl_option *option,
437 const char *base_option);
438 extern const char *candidates_list_and_hint (const char *arg, char *&str,
439 const auto_vec <const char *> &
440 candidates);
441
370 #endif 442 #endif