aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c133
1 files changed, 64 insertions, 69 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 7a275e1..3d51566 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1020,23 +1020,21 @@ static const struct compiler default_compilers[] =
static const int n_default_compilers = ARRAY_SIZE (default_compilers) - 1;
typedef char *char_p; /* For DEF_VEC_P. */
-DEF_VEC_P(char_p);
-DEF_VEC_ALLOC_P(char_p,heap);
/* A vector of options to give to the linker.
These options are accumulated by %x,
and substituted into the linker command with %X. */
-static VEC(char_p,heap) *linker_options;
+static vec<char_p> linker_options;
/* A vector of options to give to the assembler.
These options are accumulated by -Wa,
and substituted into the assembler command with %Y. */
-static VEC(char_p,heap) *assembler_options;
+static vec<char_p> assembler_options;
/* A vector of options to give to the preprocessor.
These options are accumulated by -Wp,
and substituted into the preprocessor command with %Z. */
-static VEC(char_p,heap) *preprocessor_options;
+static vec<char_p> preprocessor_options;
static char *
skip_whitespace (char *p)
@@ -1563,12 +1561,10 @@ set_spec (const char *name, const char *spec, bool user_p)
/* Accumulate a command (program name and args), and run it. */
typedef const char *const_char_p; /* For DEF_VEC_P. */
-DEF_VEC_P(const_char_p);
-DEF_VEC_ALLOC_P(const_char_p,heap);
/* Vector of pointers to arguments in the current line of specifications. */
-static VEC(const_char_p,heap) *argbuf;
+static vec<const_char_p> argbuf;
/* Position in the argbuf vector containing the name of the output file
(the value associated with the "-o" flag). */
@@ -1607,7 +1603,7 @@ static int signal_count;
static void
alloc_args (void)
{
- argbuf = VEC_alloc (const_char_p, heap, 10);
+ argbuf.create (10);
}
/* Clear out the vector of arguments (after a command is executed). */
@@ -1615,7 +1611,7 @@ alloc_args (void)
static void
clear_args (void)
{
- VEC_truncate (const_char_p, argbuf, 0);
+ argbuf.truncate (0);
}
/* Add one argument to the vector at the end.
@@ -1628,10 +1624,10 @@ clear_args (void)
static void
store_arg (const char *arg, int delete_always, int delete_failure)
{
- VEC_safe_push (const_char_p, heap, argbuf, arg);
+ argbuf.safe_push (arg);
if (strcmp (arg, "-o") == 0)
- have_o_argbuf_index = VEC_length (const_char_p, argbuf);
+ have_o_argbuf_index = argbuf.length ();
if (delete_always || delete_failure)
{
const char *p;
@@ -2545,14 +2541,14 @@ execute (void)
if (wrapper_string)
{
string = find_a_file (&exec_prefixes,
- VEC_index (const_char_p, argbuf, 0), X_OK, false);
+ argbuf[0], X_OK, false);
if (string)
- VEC_replace (const_char_p, argbuf, 0, string);
+ argbuf[0] = string;
insert_wrapper (wrapper_string);
}
/* Count # of piped commands. */
- for (n_commands = 1, i = 0; VEC_iterate (const_char_p, argbuf, i, arg); i++)
+ for (n_commands = 1, i = 0; argbuf.iterate (i, &arg); i++)
if (strcmp (arg, "|") == 0)
n_commands++;
@@ -2563,10 +2559,10 @@ execute (void)
and record info about each one.
Also search for the programs that are to be run. */
- VEC_safe_push (const_char_p, heap, argbuf, 0);
+ argbuf.safe_push (0);
- commands[0].prog = VEC_index (const_char_p, argbuf, 0); /* first command. */
- commands[0].argv = VEC_address (const_char_p, argbuf);
+ commands[0].prog = argbuf[0]; /* first command. */
+ commands[0].argv = argbuf.address ();
if (!wrapper_string)
{
@@ -2574,17 +2570,17 @@ execute (void)
commands[0].argv[0] = (string) ? string : commands[0].argv[0];
}
- for (n_commands = 1, i = 0; VEC_iterate (const_char_p, argbuf, i, arg); i++)
+ for (n_commands = 1, i = 0; argbuf.iterate (i, &arg); i++)
if (arg && strcmp (arg, "|") == 0)
{ /* each command. */
#if defined (__MSDOS__) || defined (OS2) || defined (VMS)
fatal_error ("-pipe not supported");
#endif
- VEC_replace (const_char_p, argbuf, i, 0); /* Termination of
+ argbuf[i] = 0; /* Termination of
command args. */
- commands[n_commands].prog = VEC_index (const_char_p, argbuf, i + 1);
+ commands[n_commands].prog = argbuf[i + 1];
commands[n_commands].argv
- = &(VEC_address (const_char_p, argbuf))[i + 1];
+ = &(argbuf.address ())[i + 1];
string = find_a_file (&exec_prefixes, commands[n_commands].prog,
X_OK, false);
if (string)
@@ -3074,20 +3070,19 @@ display_help (void)
static void
add_preprocessor_option (const char *option, int len)
{
- VEC_safe_push (char_p, heap, preprocessor_options,
- save_string (option, len));
+ preprocessor_options.safe_push (save_string (option, len));
}
static void
add_assembler_option (const char *option, int len)
{
- VEC_safe_push (char_p, heap, assembler_options, save_string (option, len));
+ assembler_options.safe_push (save_string (option, len));
}
static void
add_linker_option (const char *option, int len)
{
- VEC_safe_push (char_p, heap, linker_options, save_string (option, len));
+ linker_options.safe_push (save_string (option, len));
}
/* Allocate space for an input file in infiles. */
@@ -4195,7 +4190,7 @@ insert_wrapper (const char *wrapper)
int i;
char *buf = xstrdup (wrapper);
char *p = buf;
- unsigned int old_length = VEC_length (const_char_p, argbuf);
+ unsigned int old_length = argbuf.length ();
do
{
@@ -4205,9 +4200,9 @@ insert_wrapper (const char *wrapper)
}
while ((p = strchr (p, ',')) != NULL);
- VEC_safe_grow (const_char_p, heap, argbuf, old_length + n);
- memmove (VEC_address (const_char_p, argbuf) + n,
- VEC_address (const_char_p, argbuf),
+ argbuf.safe_grow (old_length + n);
+ memmove (argbuf.address () + n,
+ argbuf.address (),
old_length * sizeof (const_char_p));
i = 0;
@@ -4219,7 +4214,7 @@ insert_wrapper (const char *wrapper)
*p = 0;
p++;
}
- VEC_replace (const_char_p, argbuf, i, p);
+ argbuf[i] = p;
i++;
}
while ((p = strchr (p, ',')) != NULL);
@@ -4240,13 +4235,13 @@ do_spec (const char *spec)
If -pipe, this forces out the last command if it ended in `|'. */
if (value == 0)
{
- if (VEC_length (const_char_p, argbuf) > 0
- && !strcmp (VEC_last (const_char_p, argbuf), "|"))
- VEC_pop (const_char_p, argbuf);
+ if (argbuf.length () > 0
+ && !strcmp (argbuf.last (), "|"))
+ argbuf.pop ();
set_collect_gcc_options ();
- if (VEC_length (const_char_p, argbuf) > 0)
+ if (argbuf.length () > 0)
value = execute ();
}
@@ -4342,7 +4337,7 @@ do_self_spec (const char *spec)
if ((switches[i].live_cond & SWITCH_IGNORE))
switches[i].live_cond |= SWITCH_IGNORE_PERMANENTLY;
- if (VEC_length (const_char_p, argbuf) > 0)
+ if (argbuf.length () > 0)
{
const char **argbuf_copy;
struct cl_decoded_option *decoded_options;
@@ -4353,12 +4348,12 @@ do_self_spec (const char *spec)
/* Create a copy of argbuf with a dummy argv[0] entry for
decode_cmdline_options_to_array. */
argbuf_copy = XNEWVEC (const char *,
- VEC_length (const_char_p, argbuf) + 1);
+ argbuf.length () + 1);
argbuf_copy[0] = "";
- memcpy (argbuf_copy + 1, VEC_address (const_char_p, argbuf),
- VEC_length (const_char_p, argbuf) * sizeof (const char *));
+ memcpy (argbuf_copy + 1, argbuf.address (),
+ argbuf.length () * sizeof (const char *));
- decode_cmdline_options_to_array (VEC_length (const_char_p, argbuf) + 1,
+ decode_cmdline_options_to_array (argbuf.length () + 1,
argbuf_copy,
CL_DRIVER, &decoded_options,
&decoded_options_count);
@@ -4502,12 +4497,12 @@ compile_input_file_p (struct infile *infile)
/* Process each member of VEC as a spec. */
static void
-do_specs_vec (VEC(char_p,heap) *vec)
+do_specs_vec (vec<char_p> vec)
{
unsigned ix;
char *opt;
- FOR_EACH_VEC_ELT (char_p, vec, ix, opt)
+ FOR_EACH_VEC_ELT (vec, ix, opt)
{
do_spec_1 (opt, 1, NULL);
/* Make each accumulated option a separate argument. */
@@ -4547,8 +4542,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
case '\n':
end_going_arg ();
- if (VEC_length (const_char_p, argbuf) > 0
- && !strcmp (VEC_last (const_char_p, argbuf), "|"))
+ if (argbuf.length () > 0
+ && !strcmp (argbuf.last (), "|"))
{
/* A `|' before the newline means use a pipe here,
but only if -pipe was specified.
@@ -4559,12 +4554,12 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
break;
}
else
- VEC_pop (const_char_p, argbuf);
+ argbuf.pop ();
}
set_collect_gcc_options ();
- if (VEC_length (const_char_p, argbuf) > 0)
+ if (argbuf.length () > 0)
{
value = execute ();
if (value)
@@ -5068,7 +5063,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
case 'W':
{
- unsigned int cur_index = VEC_length (const_char_p, argbuf);
+ unsigned int cur_index = argbuf.length ();
/* Handle the {...} following the %W. */
if (*p != '{')
fatal_error ("spec %qs has invalid %<%%W%c%>", spec, *p);
@@ -5078,8 +5073,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
end_going_arg ();
/* If any args were output, mark the last one for deletion
on failure. */
- if (VEC_length (const_char_p, argbuf) != cur_index)
- record_temp_file (VEC_last (const_char_p, argbuf), 0, 1);
+ if (argbuf.length () != cur_index)
+ record_temp_file (argbuf.last (), 0, 1);
break;
}
@@ -5099,7 +5094,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
string = save_string (p1 + 1, p - p1 - 2);
/* See if we already recorded this option. */
- FOR_EACH_VEC_ELT (char_p, linker_options, ix, opt)
+ FOR_EACH_VEC_ELT (linker_options, ix, opt)
if (! strcmp (string, opt))
{
free (string);
@@ -5384,7 +5379,7 @@ eval_spec_function (const char *func, const char *args)
const char *funcval;
/* Saved spec processing context. */
- VEC(const_char_p,heap) *save_argbuf;
+ vec<const_char_p> save_argbuf;
int save_arg_going;
int save_delete_this_arg;
@@ -5434,11 +5429,11 @@ eval_spec_function (const char *func, const char *args)
/* argbuf_index is an index for the next argument to be inserted, and
so contains the count of the args already inserted. */
- funcval = (*sf->func) (VEC_length (const_char_p, argbuf),
- VEC_address (const_char_p, argbuf));
+ funcval = (*sf->func) (argbuf.length (),
+ argbuf.address ());
/* Pop the spec processing context. */
- VEC_free (const_char_p, heap, argbuf);
+ argbuf.release ();
argbuf = save_argbuf;
arg_going = save_arg_going;
@@ -6398,10 +6393,10 @@ main (int argc, char **argv)
&& !no_sysroot_suffix
&& do_spec_2 (sysroot_suffix_spec) == 0)
{
- if (VEC_length (const_char_p, argbuf) > 1)
+ if (argbuf.length () > 1)
error ("spec failure: more than one arg to SYSROOT_SUFFIX_SPEC");
- else if (VEC_length (const_char_p, argbuf) == 1)
- target_sysroot_suffix = xstrdup (VEC_last (const_char_p, argbuf));
+ else if (argbuf.length () == 1)
+ target_sysroot_suffix = xstrdup (argbuf.last ());
}
#ifdef HAVE_LD_SYSROOT
@@ -6422,10 +6417,10 @@ main (int argc, char **argv)
&& !no_sysroot_suffix
&& do_spec_2 (sysroot_hdrs_suffix_spec) == 0)
{
- if (VEC_length (const_char_p, argbuf) > 1)
+ if (argbuf.length () > 1)
error ("spec failure: more than one arg to SYSROOT_HEADERS_SUFFIX_SPEC");
- else if (VEC_length (const_char_p, argbuf) == 1)
- target_sysroot_hdrs_suffix = xstrdup (VEC_last (const_char_p, argbuf));
+ else if (argbuf.length () == 1)
+ target_sysroot_hdrs_suffix = xstrdup (argbuf.last ());
}
/* Look for startfiles in the standard places. */
@@ -6435,7 +6430,7 @@ main (int argc, char **argv)
{
const char *arg;
int ndx;
- FOR_EACH_VEC_ELT (const_char_p, argbuf, ndx, arg)
+ FOR_EACH_VEC_ELT (argbuf, ndx, arg)
add_sysrooted_prefix (&startfile_prefixes, arg, "BINUTILS",
PREFIX_PRIORITY_LAST, 0, 1);
}
@@ -8278,20 +8273,20 @@ compare_debug_dump_opt_spec_function (int arg,
do_spec_2 ("%{fdump-final-insns=*:%*}");
do_spec_1 (" ", 0, NULL);
- if (VEC_length (const_char_p, argbuf) > 0
- && strcmp (argv[VEC_length (const_char_p, argbuf) - 1], "."))
+ if (argbuf.length () > 0
+ && strcmp (argv[argbuf.length () - 1], "."))
{
if (!compare_debug)
return NULL;
- name = xstrdup (argv[VEC_length (const_char_p, argbuf) - 1]);
+ name = xstrdup (argv[argbuf.length () - 1]);
ret = NULL;
}
else
{
const char *ext = NULL;
- if (VEC_length (const_char_p, argbuf) > 0)
+ if (argbuf.length () > 0)
{
do_spec_2 ("%{o*:%*}%{!o:%{!S:%b%O}%{S:%b.s}}");
ext = ".gkd";
@@ -8303,9 +8298,9 @@ compare_debug_dump_opt_spec_function (int arg,
do_spec_1 (" ", 0, NULL);
- gcc_assert (VEC_length (const_char_p, argbuf) > 0);
+ gcc_assert (argbuf.length () > 0);
- name = concat (VEC_last (const_char_p, argbuf), ext, NULL);
+ name = concat (argbuf.last (), ext, NULL);
ret = concat ("-fdump-final-insns=", name, NULL);
}
@@ -8353,9 +8348,9 @@ compare_debug_self_opt_spec_function (int arg,
do_spec_2 ("%{c|S:%{o*:%*}}");
do_spec_1 (" ", 0, NULL);
- if (VEC_length (const_char_p, argbuf) > 0)
+ if (argbuf.length () > 0)
debug_auxbase_opt = concat ("-auxbase-strip ",
- VEC_last (const_char_p, argbuf),
+ argbuf.last (),
NULL);
else
debug_auxbase_opt = NULL;