/* Common initialization before parsing options. */ unsigned int c_common_init_options (unsigned int argc, const char **argv) { static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX}; unsigned int i, result; /* This is conditionalized only because that is the way the front ends used to do it. Maybe this should be unconditional? */ if (c_dialect_cxx ()) { /* By default wrap lines at 80 characters. Is getenv ("COLUMNS") preferable? */ diagnostic_line_cutoff (global_dc) = 80; /* By default, emit location information once for every diagnostic message. */ diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE; } parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89, ident_hash, &line_table); cpp_opts = cpp_get_options (parse_in); cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS; cpp_opts->objc = c_dialect_objc (); /* Reset to avoid warnings on internal definitions. We set it just before passing on command-line options to cpplib. */ cpp_opts->warn_dollars = 0; flag_exceptions = c_dialect_cxx (); warn_pointer_arith = c_dialect_cxx (); warn_write_strings = c_dialect_cxx(); deferred_opts = XNEWVEC (struct deferred_opt, argc); result = lang_flags[c_language]; if (c_language == clk_c) { /* If preprocessing assembly language, accept any of the C-family front end options since the driver may pass them through. */ for (i = 1; i < argc; i++) if (! strcmp (argv[i], "-lang-asm")) { result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX; break; } #ifdef CL_Fortran for (i = 1; i < argc; i++) if (! strcmp (argv[i], "-lang-fortran")) { result |= CL_Fortran; break; } #endif } return result; }
/* Common diagnostics initialization. */ void c_common_initialize_diagnostics (diagnostic_context *context) { /* This is conditionalized only because that is the way the front ends used to do it. Maybe this should be unconditional? */ if (c_dialect_cxx ()) { /* By default wrap lines at 80 characters. Is getenv ("COLUMNS") preferable? */ diagnostic_line_cutoff (context) = 80; /* By default, emit location information once for every diagnostic message. */ diagnostic_prefixing_rule (context) = DIAGNOSTICS_SHOW_PREFIX_ONCE; } context->opt_permissive = OPT_fpermissive; }
static int common_handle_option (size_t scode, const char *arg, int value) { enum opt_code code = (enum opt_code) scode; switch (code) { /* APPLE LOCAL begin fat builds */ case OPT_arch: /* Ignore for now. */ break; /* APPLE LOCAL end fat builds */ case OPT__help: print_help (); exit_after_options = true; break; case OPT__param: handle_param (arg); break; case OPT__target_help: display_target_options (); exit_after_options = true; break; case OPT__version: print_version (stderr, ""); exit_after_options = true; break; case OPT_G: g_switch_value = value; g_switch_set = true; break; case OPT_O: case OPT_Os: /* Currently handled in a prescan. */ break; case OPT_W: /* For backward compatibility, -W is the same as -Wextra. */ set_Wextra (value); break; case OPT_Wextra: set_Wextra (value); break; case OPT_Wlarger_than_: larger_than_size = value; warn_larger_than = value != -1; break; case OPT_Wstrict_aliasing: case OPT_Wstrict_aliasing_: warn_strict_aliasing = value; break; case OPT_Wunused: set_Wunused (value); break; case OPT_aux_info: case OPT_aux_info_: aux_info_file_name = arg; flag_gen_aux_info = 1; break; case OPT_auxbase: aux_base_name = arg; break; /* APPLE LOCAL begin LLVM */ case OPT_mllvm: llvm_optns = arg; break; /* APPLE LOCAL end LLVM */ case OPT_auxbase_strip: { char *tmp = xstrdup (arg); strip_off_ending (tmp, strlen (tmp)); if (tmp[0]) aux_base_name = tmp; } break; case OPT_d: decode_d_option (arg); break; case OPT_dumpbase: dump_base_name = arg; break; /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ /* APPLE LOCAL begin falign-jumps-max-skip */ case OPT_falign_jumps_max_skip_: align_jumps_max_skip = value; break; case OPT_falign_loops_max_skip_: align_loops_max_skip = value; break; /* APPLE LOCAL end falign-jumps-max-skip */ /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ /* APPLE LOCAL begin predictive compilation */ case OPT_fpredictive_compilation: predictive_compilation = 0; break; case OPT_fpredictive_compilation_: { char* buf = xmalloc (strlen(arg) + 1); sprintf (buf, "%d", value); if (strcmp(buf, arg)) { error ("argument to \"-fpredictive-compilation=\" should be a valid non-negative integer instead of \"%s\"", arg); value = 0; } free(buf); predictive_compilation = value; break; } /* APPLE LOCAL end predictive compilation */ case OPT_fbranch_probabilities: flag_branch_probabilities_set = true; break; case OPT_fcall_used_: fix_register (arg, 0, 1); break; case OPT_fcall_saved_: fix_register (arg, 0, 0); break; case OPT_fdiagnostics_show_location_: if (!strcmp (arg, "once")) diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE; else if (!strcmp (arg, "every-line")) diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; else return 0; break; case OPT_fdump_: if (!dump_switch_p (arg)) return 0; break; case OPT_ffast_math: set_fast_math_flags (value); break; case OPT_ffixed_: fix_register (arg, 1, 1); break; case OPT_finline_limit_: case OPT_finline_limit_eq: set_param_value ("max-inline-insns-single", value / 2); set_param_value ("max-inline-insns-auto", value / 2); break; case OPT_fmessage_length_: pp_set_line_maximum_length (global_dc->printer, value); break; case OPT_fpack_struct_: if (value <= 0 || (value & (value - 1)) || value > 16) error("structure alignment must be a small power of two, not %d", value); else { initial_max_fld_align = value; maximum_field_alignment = value * BITS_PER_UNIT; } break; case OPT_fpeel_loops: flag_peel_loops_set = true; break; case OPT_fprofile_arcs: profile_arc_flag_set = true; break; /* APPLE LOCAL begin add fuse-profile */ case OPT_fuse_profile: /* APPLE LOCAL end add fuse-profile */ case OPT_fprofile_use: if (!flag_branch_probabilities_set) flag_branch_probabilities = value; if (!flag_profile_values_set) flag_profile_values = value; if (!flag_unroll_loops_set) flag_unroll_loops = value; if (!flag_peel_loops_set) flag_peel_loops = value; if (!flag_tracer_set) flag_tracer = value; if (!flag_value_profile_transformations_set) flag_value_profile_transformations = value; #ifdef HAVE_prefetch if (0 && !flag_speculative_prefetching_set) flag_speculative_prefetching = value; #endif break; /* APPLE LOCAL begin add fcreate-profile */ case OPT_fcreate_profile: /* APPLE LOCAL end add fcreate-profile */ case OPT_fprofile_generate: if (!profile_arc_flag_set) profile_arc_flag = value; if (!flag_profile_values_set) flag_profile_values = value; if (!flag_value_profile_transformations_set) flag_value_profile_transformations = value; if (!flag_unroll_loops_set) flag_unroll_loops = value; #ifdef HAVE_prefetch if (0 && !flag_speculative_prefetching_set) flag_speculative_prefetching = value; #endif break; case OPT_fprofile_values: flag_profile_values_set = true; break; case OPT_fvisibility_: { if (!strcmp(arg, "default")) default_visibility = VISIBILITY_DEFAULT; else if (!strcmp(arg, "internal")) default_visibility = VISIBILITY_INTERNAL; else if (!strcmp(arg, "hidden")) default_visibility = VISIBILITY_HIDDEN; else if (!strcmp(arg, "protected")) default_visibility = VISIBILITY_PROTECTED; else error ("unrecognised visibility value \"%s\"", arg); } break; case OPT_fvpt: flag_value_profile_transformations_set = true; break; case OPT_fspeculative_prefetching: flag_speculative_prefetching_set = true; break; case OPT_frandom_seed: /* The real switch is -fno-random-seed. */ if (value) return 0; flag_random_seed = NULL; break; case OPT_frandom_seed_: flag_random_seed = arg; break; /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ case OPT_fsched_stalled_insns_: flag_sched_stalled_insns = value; if (flag_sched_stalled_insns == 0) flag_sched_stalled_insns = -1; break; /* APPLE LOCAL begin optimization pragmas 3124235/3420242 */ /* APPLE LOCAL end optimization pragmas 3124235/3420242 */ case OPT_fstack_limit: /* The real switch is -fno-stack-limit. */ if (value) return 0; stack_limit_rtx = NULL_RTX; break; case OPT_fstack_limit_register_: { int reg = decode_reg_name (arg); if (reg < 0) error ("unrecognized register name \"%s\"", arg); else stack_limit_rtx = gen_rtx_REG (Pmode, reg); } break; case OPT_fstack_limit_symbol_: stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (arg)); break; case OPT_ftree_vectorizer_verbose_: vect_set_verbosity_level (arg); break; case OPT_ftls_model_: if (!strcmp (arg, "global-dynamic")) flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC; else if (!strcmp (arg, "local-dynamic")) flag_tls_default = TLS_MODEL_LOCAL_DYNAMIC; else if (!strcmp (arg, "initial-exec")) flag_tls_default = TLS_MODEL_INITIAL_EXEC; else if (!strcmp (arg, "local-exec")) flag_tls_default = TLS_MODEL_LOCAL_EXEC; else warning ("unknown tls-model \"%s\"", arg); break; case OPT_ftracer: flag_tracer_set = true; break; case OPT_funroll_loops: flag_unroll_loops_set = true; break; /* APPLE LOCAL begin fwritable strings */ case OPT_fwritable_strings: flag_writable_strings = value; break; /* APPLE LOCAL end fwritable strings */ case OPT_g: set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg); break; case OPT_gcoff: set_debug_level (SDB_DEBUG, false, arg); break; case OPT_gdwarf_2: set_debug_level (DWARF2_DEBUG, false, arg); break; case OPT_ggdb: set_debug_level (NO_DEBUG, 2, arg); break; case OPT_gstabs: case OPT_gstabs_: set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg); break; case OPT_gvms: set_debug_level (VMS_DEBUG, false, arg); break; case OPT_gxcoff: case OPT_gxcoff_: set_debug_level (XCOFF_DEBUG, code == OPT_gxcoff_, arg); break; case OPT_m: set_target_switch (arg); break; case OPT_o: asm_file_name = arg; break; case OPT_pedantic_errors: flag_pedantic_errors = pedantic = 1; break; default: /* If the flag was handled in a standard way, assume the lack of processing here is intentional. */ /* APPLE LOCAL optimization pragmas 3124235/3420242 */ if (cl_options[scode].flag_var || cl_options[scode].access_flag) break; abort (); } return 1; }