This changes some uses of VEC in a few parsers to std::vector instead.
Tested by the buildbot.
gdb/ChangeLog
2018-08-28 Tom Tromey <tom@tromey.com>
* c-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
(token_fifo): Now a std::vector.
(yylex, c_parse): Update.
* d-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
(token_fifo): Now a std::vector.
(yylex, d_parse): Update.
* go-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
(token_fifo): Now a std::vector.
(yylex, go_parse): Update.
+2018-08-28 Tom Tromey <tom@tromey.com>
+
+ * c-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
+ (token_fifo): Now a std::vector.
+ (yylex, c_parse): Update.
+ * d-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
+ (token_fifo): Now a std::vector.
+ (yylex, d_parse): Update.
+ * go-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
+ (token_fifo): Now a std::vector.
+ (yylex, go_parse): Update.
+
2018-08-28 Simon Marchi <simon.marchi@ericsson.com>
* parser-defs.h (struct type_stack) <elements>: Change type to
}
/* An object of this type is pushed on a FIFO by the "outer" lexer. */
-typedef struct
+struct token_and_value
{
int token;
YYSTYPE value;
-} token_and_value;
-
-DEF_VEC_O (token_and_value);
+};
/* A FIFO of tokens that have been read but not yet returned to the
parser. */
-static VEC (token_and_value) *token_fifo;
+static std::vector<token_and_value> token_fifo;
/* Non-zero if the lexer should return tokens from the FIFO. */
static int popping;
const struct block *search_block;
bool is_quoted_name, last_lex_was_structop;
- if (popping && !VEC_empty (token_and_value, token_fifo))
+ if (popping && !token_fifo.empty ())
goto do_pop;
popping = 0;
/* Read any sequence of alternating "::" and name-like tokens into
the token FIFO. */
current.value = yylval;
- VEC_safe_push (token_and_value, token_fifo, ¤t);
+ token_fifo.push_back (current);
last_was_coloncolon = current.token == COLONCOLON;
while (1)
{
Subsequent ones do not have any special meaning. */
current.token = lex_one_token (pstate, &ignore);
current.value = yylval;
- VEC_safe_push (token_and_value, token_fifo, ¤t);
+ token_fifo.push_back (current);
if ((last_was_coloncolon && current.token != NAME)
|| (!last_was_coloncolon && current.token != COLONCOLON))
/* We always read one extra token, so compute the number of tokens
to examine accordingly. */
- last_to_examine = VEC_length (token_and_value, token_fifo) - 2;
+ last_to_examine = token_fifo.size () - 2;
next_to_examine = 0;
- current = *VEC_index (token_and_value, token_fifo, next_to_examine);
+ current = token_fifo[next_to_examine];
++next_to_examine;
name_obstack.clear ();
while (next_to_examine <= last_to_examine)
{
- token_and_value *next;
+ token_and_value next;
- next = VEC_index (token_and_value, token_fifo, next_to_examine);
+ next = token_fifo[next_to_examine];
++next_to_examine;
- if (next->token == NAME && last_was_coloncolon)
+ if (next.token == NAME && last_was_coloncolon)
{
int classification;
- yylval = next->value;
+ yylval = next.value;
classification = classify_inner_name (pstate, search_block,
context_type);
/* We keep going until we either run out of names, or until
/* We don't want to put a leading "::" into the name. */
obstack_grow_str (&name_obstack, "::");
}
- obstack_grow (&name_obstack, next->value.sval.ptr,
- next->value.sval.length);
+ obstack_grow (&name_obstack, next.value.sval.ptr,
+ next.value.sval.length);
yylval.sval.ptr = (const char *) obstack_base (&name_obstack);
yylval.sval.length = obstack_object_size (&name_obstack);
context_type = yylval.tsym.type;
}
- else if (next->token == COLONCOLON && !last_was_coloncolon)
+ else if (next.token == COLONCOLON && !last_was_coloncolon)
last_was_coloncolon = 1;
else
{
current.value.sval.ptr,
current.value.sval.length);
- VEC_replace (token_and_value, token_fifo, 0, ¤t);
+ token_fifo[0] = current;
if (checkpoint > 1)
- VEC_block_remove (token_and_value, token_fifo, 1, checkpoint - 1);
+ token_fifo.erase (token_fifo.begin () + 1,
+ token_fifo.begin () + checkpoint);
}
do_pop:
- current = *VEC_index (token_and_value, token_fifo, 0);
- VEC_ordered_remove (token_and_value, token_fifo, 0);
+ current = token_fifo[0];
+ token_fifo.erase (token_fifo.begin ());
yylval = current.value;
return current.token;
}
last_was_structop = false;
saw_name_at_eof = 0;
- VEC_free (token_and_value, token_fifo);
+ token_fifo.clear ();
popping = 0;
name_obstack.clear ();
}
/* An object of this type is pushed on a FIFO by the "outer" lexer. */
-typedef struct
+struct token_and_value
{
int token;
YYSTYPE value;
-} token_and_value;
+};
-DEF_VEC_O (token_and_value);
/* A FIFO of tokens that have been read but not yet returned to the
parser. */
-static VEC (token_and_value) *token_fifo;
+static std::vector<token_and_value> token_fifo;
/* Non-zero if the lexer should return tokens from the FIFO. */
static int popping;
int last_to_examine, next_to_examine, checkpoint;
const struct block *search_block;
- if (popping && !VEC_empty (token_and_value, token_fifo))
+ if (popping && !token_fifo.empty ())
goto do_pop;
popping = 0;
/* Read any sequence of alternating "." and identifier tokens into
the token FIFO. */
current.value = yylval;
- VEC_safe_push (token_and_value, token_fifo, ¤t);
+ token_fifo.push_back (current);
last_was_dot = current.token == '.';
while (1)
{
current.token = lex_one_token (pstate);
current.value = yylval;
- VEC_safe_push (token_and_value, token_fifo, ¤t);
+ token_fifo.push_back (current);
if ((last_was_dot && current.token != IDENTIFIER)
|| (!last_was_dot && current.token != '.'))
/* We always read one extra token, so compute the number of tokens
to examine accordingly. */
- last_to_examine = VEC_length (token_and_value, token_fifo) - 2;
+ last_to_examine = token_fifo.size () - 2;
next_to_examine = 0;
- current = *VEC_index (token_and_value, token_fifo, next_to_examine);
+ current = token_fifo[next_to_examine];
++next_to_examine;
/* If we are not dealing with a typename, now is the time to find out. */
while (next_to_examine <= last_to_examine)
{
- token_and_value *next;
+ token_and_value next;
- next = VEC_index (token_and_value, token_fifo, next_to_examine);
+ next = token_fifo[next_to_examine];
++next_to_examine;
- if (next->token == IDENTIFIER && last_was_dot)
+ if (next.token == IDENTIFIER && last_was_dot)
{
/* Update the partial name we are constructing. */
obstack_grow_str (&name_obstack, ".");
- obstack_grow (&name_obstack, next->value.sval.ptr,
- next->value.sval.length);
+ obstack_grow (&name_obstack, next.value.sval.ptr,
+ next.value.sval.length);
yylval.sval.ptr = (char *) obstack_base (&name_obstack);
yylval.sval.length = obstack_object_size (&name_obstack);
if (current.token == TYPENAME)
{
/* Install it as the first token in the FIFO. */
- VEC_replace (token_and_value, token_fifo, 0, ¤t);
- VEC_block_remove (token_and_value, token_fifo, 1,
- next_to_examine - 1);
+ token_fifo[0] = current;
+ token_fifo.erase (token_fifo.begin () + 1,
+ token_fifo.begin () + next_to_examine);
break;
}
}
- else if (next->token == '.' && !last_was_dot)
+ else if (next.token == '.' && !last_was_dot)
last_was_dot = 1;
else
{
/* Reset our current token back to the start, if we found nothing
this means that we will just jump to do pop. */
- current = *VEC_index (token_and_value, token_fifo, 0);
+ current = token_fifo[0];
next_to_examine = 1;
}
if (current.token != TYPENAME && current.token != '.')
while (next_to_examine <= last_to_examine)
{
- token_and_value *next;
+ token_and_value next;
- next = VEC_index (token_and_value, token_fifo, next_to_examine);
+ next = token_fifo[next_to_examine];
++next_to_examine;
- if (next->token == IDENTIFIER && last_was_dot)
+ if (next.token == IDENTIFIER && last_was_dot)
{
int classification;
- yylval = next->value;
+ yylval = next.value;
classification = classify_inner_name (pstate, search_block,
context_type);
/* We keep going until we either run out of names, or until
/* We don't want to put a leading "." into the name. */
obstack_grow_str (&name_obstack, ".");
}
- obstack_grow (&name_obstack, next->value.sval.ptr,
- next->value.sval.length);
+ obstack_grow (&name_obstack, next.value.sval.ptr,
+ next.value.sval.length);
yylval.sval.ptr = (char *) obstack_base (&name_obstack);
yylval.sval.length = obstack_object_size (&name_obstack);
context_type = yylval.tsym.type;
}
- else if (next->token == '.' && !last_was_dot)
+ else if (next.token == '.' && !last_was_dot)
last_was_dot = 1;
else
{
the FIFO, and delete the other constituent tokens. */
if (checkpoint > 0)
{
- VEC_replace (token_and_value, token_fifo, 0, ¤t);
+ token_fifo[0] = current;
if (checkpoint > 1)
- VEC_block_remove (token_and_value, token_fifo, 1, checkpoint - 1);
+ token_fifo.erase (token_fifo.begin () + 1,
+ token_fifo.begin () + checkpoint);
}
do_pop:
- current = *VEC_index (token_and_value, token_fifo, 0);
- VEC_ordered_remove (token_and_value, token_fifo, 0);
+ current = token_fifo[0];
+ token_fifo.erase (token_fifo.begin ());
yylval = current.value;
return current.token;
}
last_was_structop = 0;
saw_name_at_eof = 0;
- VEC_free (token_and_value, token_fifo);
+ token_fifo.clear ();
popping = 0;
name_obstack.clear ();
}
/* An object of this type is pushed on a FIFO by the "outer" lexer. */
-typedef struct
+struct token_and_value
{
int token;
YYSTYPE value;
-} token_and_value;
-
-DEF_VEC_O (token_and_value);
+};
/* A FIFO of tokens that have been read but not yet returned to the
parser. */
-static VEC (token_and_value) *token_fifo;
+static std::vector<token_and_value> token_fifo;
/* Non-zero if the lexer should return tokens from the FIFO. */
static int popping;
{
token_and_value current, next;
- if (popping && !VEC_empty (token_and_value, token_fifo))
+ if (popping && !token_fifo.empty ())
{
- token_and_value tv = *VEC_index (token_and_value, token_fifo, 0);
- VEC_ordered_remove (token_and_value, token_fifo, 0);
+ token_and_value tv = token_fifo[0];
+ token_fifo.erase (token_fifo.begin ());
yylval = tv.value;
/* There's no need to fall through to handle package.name
as that can never happen here. In theory. */
}
}
- VEC_safe_push (token_and_value, token_fifo, &next);
- VEC_safe_push (token_and_value, token_fifo, &name2);
+ token_fifo.push_back (next);
+ token_fifo.push_back (name2);
}
else
- {
- VEC_safe_push (token_and_value, token_fifo, &next);
- }
+ token_fifo.push_back (next);
/* If we arrive here we don't have a package-qualified name. */
last_was_structop = 0;
saw_name_at_eof = 0;
- VEC_free (token_and_value, token_fifo);
+ token_fifo.clear ();
popping = 0;
name_obstack.clear ();