ada_exception_catchpoint_cond_string (const char *excep_string,
enum ada_exception_catchpoint_kind ex)
{
- int i;
bool is_standard_exc = false;
std::string result;
breakpoint condition is to use its fully-qualified named:
e.g. my_package.constraint_error. */
- for (i = 0; i < sizeof (standard_exc) / sizeof (char *); i++)
+ for (const char *name : standard_exc)
{
- if (strcmp (standard_exc [i], excep_string) == 0)
+ if (strcmp (name, excep_string) == 0)
{
is_standard_exc = true;
break;
static int
ada_is_non_standard_exception_sym (struct symbol *sym)
{
- int i;
-
if (!ada_is_exception_sym (sym))
return 0;
- for (i = 0; i < ARRAY_SIZE (standard_exc); i++)
- if (strcmp (sym->linkage_name (), standard_exc[i]) == 0)
+ for (const char *name : standard_exc)
+ if (strcmp (sym->linkage_name (), name) == 0)
return 0; /* A standard exception. */
/* Numeric_Error is also a standard exception, so exclude it.
ada_add_standard_exceptions (compiled_regex *preg,
std::vector<ada_exc_info> *exceptions)
{
- int i;
-
- for (i = 0; i < ARRAY_SIZE (standard_exc); i++)
+ for (const char *name : standard_exc)
{
- if (preg == NULL
- || preg->exec (standard_exc[i], 0, NULL, 0) == 0)
+ if (preg == NULL || preg->exec (name, 0, NULL, 0) == 0)
{
struct bound_minimal_symbol msymbol
- = ada_lookup_simple_minsym (standard_exc[i]);
+ = ada_lookup_simple_minsym (name);
if (msymbol.minsym != NULL)
{
struct ada_exc_info info
- = {standard_exc[i], BMSYMBOL_VALUE_ADDRESS (msymbol)};
+ = {name, BMSYMBOL_VALUE_ADDRESS (msymbol)};
exceptions->push_back (info);
}
so we roughly double the table size each time. After we fall off
the end of this table, we just double. Don't laugh --- there have
been executables sighted with a gigabyte of debug info. */
- static unsigned long sizes[] = {
+ static const unsigned long sizes[] = {
1021, 2053, 4099, 8191, 16381, 32771,
65537, 131071, 262144, 524287, 1048573, 2097143,
4194301, 8388617, 16777213, 33554467, 67108859, 134217757,
/* Find the next size. */
new_num_buckets = m_num_buckets * 2;
- for (i = 0; i < (sizeof (sizes) / sizeof (sizes[0])); i++)
- if (sizes[i] > m_num_buckets)
+ for (unsigned long a_size : sizes)
+ if (a_size > m_num_buckets)
{
- new_num_buckets = sizes[i];
+ new_num_buckets = a_size;
break;
}
{
int c;
int namelen;
- unsigned int i;
const char *tokstart;
bool saw_structop = last_was_structop;
tokstart = pstate->lexptr;
/* See if it is a special token of length 3. */
- for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
- if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
+ for (const auto &token : tokentab3)
+ if (strncmp (tokstart, token.oper, 3) == 0)
{
- if ((tokentab3[i].flags & FLAG_CXX) != 0
+ if ((token.flags & FLAG_CXX) != 0
&& par_state->language ()->la_language != language_cplus)
break;
- gdb_assert ((tokentab3[i].flags & FLAG_C) == 0);
+ gdb_assert ((token.flags & FLAG_C) == 0);
pstate->lexptr += 3;
- yylval.opcode = tokentab3[i].opcode;
- return tokentab3[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
/* See if it is a special token of length 2. */
- for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
- if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
+ for (const auto &token : tokentab2)
+ if (strncmp (tokstart, token.oper, 2) == 0)
{
- if ((tokentab2[i].flags & FLAG_CXX) != 0
+ if ((token.flags & FLAG_CXX) != 0
&& par_state->language ()->la_language != language_cplus)
break;
- gdb_assert ((tokentab2[i].flags & FLAG_C) == 0);
+ gdb_assert ((token.flags & FLAG_C) == 0);
pstate->lexptr += 2;
- yylval.opcode = tokentab2[i].opcode;
- if (tokentab2[i].token == ARROW)
+ yylval.opcode = token.opcode;
+ if (token.token == ARROW)
last_was_structop = 1;
- return tokentab2[i].token;
+ return token.token;
}
switch (c = *tokstart)
/* Catch specific keywords. */
std::string copy = copy_name (yylval.sval);
- for (i = 0; i < sizeof ident_tokens / sizeof ident_tokens[0]; i++)
- if (copy == ident_tokens[i].oper)
+ for (const auto &token : ident_tokens)
+ if (copy == token.oper)
{
- if ((ident_tokens[i].flags & FLAG_CXX) != 0
+ if ((token.flags & FLAG_CXX) != 0
&& par_state->language ()->la_language != language_cplus)
break;
- if ((ident_tokens[i].flags & FLAG_C) != 0
+ if ((token.flags & FLAG_C) != 0
&& par_state->language ()->la_language != language_c
&& par_state->language ()->la_language != language_objc)
break;
- if ((ident_tokens[i].flags & FLAG_SHADOW) != 0)
+ if ((token.flags & FLAG_SHADOW) != 0)
{
struct field_of_this_result is_a_field_of_this;
/* It is ok to always set this, even though we don't always
strictly need to. */
- yylval.opcode = ident_tokens[i].opcode;
- return ident_tokens[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
if (*tokstart == '$')
name[ret_comp->u.s_name.len] = '\0';
/* Ignore any typedefs that should not be substituted. */
- for (int i = 0; i < ARRAY_SIZE (ignore_typedefs); ++i)
+ for (const char *ignorable : ignore_typedefs)
{
- if (strcmp (name, ignore_typedefs[i]) == 0)
+ if (strcmp (name, ignorable) == 0)
return 0;
}
{
int c;
int namelen;
- unsigned int i;
const char *tokstart;
int saw_structop = last_was_structop;
tokstart = pstate->lexptr;
/* See if it is a special token of length 3. */
- for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
- if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
+ for (const auto &token : tokentab3)
+ if (strncmp (tokstart, token.oper, 3) == 0)
{
pstate->lexptr += 3;
- yylval.opcode = tokentab3[i].opcode;
- return tokentab3[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
/* See if it is a special token of length 2. */
- for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
- if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
+ for (const auto &token : tokentab2)
+ if (strncmp (tokstart, token.oper, 2) == 0)
{
pstate->lexptr += 2;
- yylval.opcode = tokentab2[i].opcode;
- return tokentab2[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
switch (c = *tokstart)
/* Catch specific keywords. */
std::string copy = copy_name (yylval.sval);
- for (i = 0; i < sizeof ident_tokens / sizeof ident_tokens[0]; i++)
- if (copy == ident_tokens[i].oper)
+ for (const auto &token : ident_tokens)
+ if (copy == token.oper)
{
/* It is ok to always set this, even though we don't always
strictly need to. */
- yylval.opcode = ident_tokens[i].opcode;
- return ident_tokens[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
if (*tokstart == '$')
if (*pstate->lexptr == '.')
{
- for (int i = 0; i < ARRAY_SIZE (boolean_values); i++)
+ for (const auto &candidate : boolean_values)
{
- if (strncasecmp (tokstart, boolean_values[i].name,
- strlen (boolean_values[i].name)) == 0)
+ if (strncasecmp (tokstart, candidate.name,
+ strlen (candidate.name)) == 0)
{
- pstate->lexptr += strlen (boolean_values[i].name);
- yylval.lval = boolean_values[i].value;
+ pstate->lexptr += strlen (candidate.name);
+ yylval.lval = candidate.value;
return BOOLEAN_LITERAL;
}
}
}
/* See if it is a Fortran operator. */
- for (int i = 0; i < ARRAY_SIZE (fortran_operators); i++)
- if (strncasecmp (tokstart, fortran_operators[i].oper,
- strlen (fortran_operators[i].oper)) == 0)
+ for (const auto &candidate : fortran_operators)
+ if (strncasecmp (tokstart, candidate.oper,
+ strlen (candidate.oper)) == 0)
{
- gdb_assert (!fortran_operators[i].case_sensitive);
- pstate->lexptr += strlen (fortran_operators[i].oper);
- yylval.opcode = fortran_operators[i].opcode;
- return fortran_operators[i].token;
+ gdb_assert (!candidate.case_sensitive);
+ pstate->lexptr += strlen (candidate.oper);
+ yylval.opcode = candidate.opcode;
+ return candidate.token;
}
switch (c = *tokstart)
/* Catch specific keywords. */
- for (int i = 0; i < ARRAY_SIZE (f77_keywords); i++)
- if (strlen (f77_keywords[i].oper) == namelen
- && ((!f77_keywords[i].case_sensitive
- && strncasecmp (tokstart, f77_keywords[i].oper, namelen) == 0)
- || (f77_keywords[i].case_sensitive
- && strncmp (tokstart, f77_keywords[i].oper, namelen) == 0)))
+ for (const auto &keyword : f77_keywords)
+ if (strlen (keyword.oper) == namelen
+ && ((!keyword.case_sensitive
+ && strncasecmp (tokstart, keyword.oper, namelen) == 0)
+ || (keyword.case_sensitive
+ && strncmp (tokstart, keyword.oper, namelen) == 0)))
{
- yylval.opcode = f77_keywords[i].opcode;
- return f77_keywords[i].token;
+ yylval.opcode = keyword.opcode;
+ return keyword.token;
}
yylval.sval.ptr = tokstart;
{
std::string tmp = copy_name (yylval.sval);
struct block_symbol result;
- enum domain_enum_tag lookup_domains[] =
+ const enum domain_enum_tag lookup_domains[] =
{
STRUCT_DOMAIN,
VAR_DOMAIN,
};
int hextype;
- for (int i = 0; i < ARRAY_SIZE (lookup_domains); ++i)
+ for (const auto &domain : lookup_domains)
{
result = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
- lookup_domains[i], NULL);
+ domain, NULL);
if (result.symbol && SYMBOL_CLASS (result.symbol) == LOC_TYPEDEF)
{
yylval.tsym.type = SYMBOL_TYPE (result.symbol);
{
int c;
int namelen;
- unsigned int i;
const char *tokstart;
int saw_structop = last_was_structop;
tokstart = par_state->lexptr;
/* See if it is a special token of length 3. */
- for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
- if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
+ for (const auto &token : tokentab3)
+ if (strncmp (tokstart, token.oper, 3) == 0)
{
par_state->lexptr += 3;
- yylval.opcode = tokentab3[i].opcode;
- return tokentab3[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
/* See if it is a special token of length 2. */
- for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
- if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
+ for (const auto &token : tokentab2)
+ if (strncmp (tokstart, token.oper, 2) == 0)
{
par_state->lexptr += 2;
- yylval.opcode = tokentab2[i].opcode;
+ yylval.opcode = token.opcode;
/* NOTE: -> doesn't exist in Go, so we don't need to watch for
setting last_was_structop here. */
- return tokentab2[i].token;
+ return token.token;
}
switch (c = *tokstart)
/* Catch specific keywords. */
std::string copy = copy_name (yylval.sval);
- for (i = 0; i < sizeof (ident_tokens) / sizeof (ident_tokens[0]); i++)
- if (copy == ident_tokens[i].oper)
+ for (const auto &token : ident_tokens)
+ if (copy == token.oper)
{
/* It is ok to always set this, even though we don't always
strictly need to. */
- yylval.opcode = ident_tokens[i].opcode;
- return ident_tokens[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
if (*tokstart == '$')
/* See if it is a special token of length 3. */
if (explen > 2)
- for (int i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
- if (strncasecmp (tokstart, tokentab3[i].oper, 3) == 0
- && (!isalpha (tokentab3[i].oper[0]) || explen == 3
+ for (const auto &token : tokentab3)
+ if (strncasecmp (tokstart, token.oper, 3) == 0
+ && (!isalpha (token.oper[0]) || explen == 3
|| (!isalpha (tokstart[3])
&& !isdigit (tokstart[3]) && tokstart[3] != '_')))
{
pstate->lexptr += 3;
- yylval.opcode = tokentab3[i].opcode;
- return tokentab3[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
/* See if it is a special token of length 2. */
if (explen > 1)
- for (int i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
- if (strncasecmp (tokstart, tokentab2[i].oper, 2) == 0
- && (!isalpha (tokentab2[i].oper[0]) || explen == 2
+ for (const auto &token : tokentab2)
+ if (strncasecmp (tokstart, token.oper, 2) == 0
+ && (!isalpha (token.oper[0]) || explen == 2
|| (!isalpha (tokstart[2])
&& !isdigit (tokstart[2]) && tokstart[2] != '_')))
{
pstate->lexptr += 2;
- yylval.opcode = tokentab2[i].opcode;
- return tokentab2[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
switch (c = *tokstart)
{
unsigned int length;
const struct token_info *token;
- int i;
int is_gdb_var = pstate->lexptr[0] == '$';
bool is_raw = false;
token = NULL;
if (!is_raw)
{
- for (i = 0; i < ARRAY_SIZE (identifier_tokens); ++i)
+ for (const auto &candidate : identifier_tokens)
{
- if (length == strlen (identifier_tokens[i].name)
- && strncmp (identifier_tokens[i].name, start, length) == 0)
+ if (length == strlen (candidate.name)
+ && strncmp (candidate.name, start, length) == 0)
{
- token = &identifier_tokens[i];
+ token = &candidate;
break;
}
}
rust_parser::lex_operator ()
{
const struct token_info *token = NULL;
- int i;
- for (i = 0; i < ARRAY_SIZE (operator_tokens); ++i)
+ for (const auto &candidate : operator_tokens)
{
- if (strncmp (operator_tokens[i].name, pstate->lexptr,
- strlen (operator_tokens[i].name)) == 0)
+ if (strncmp (candidate.name, pstate->lexptr,
+ strlen (candidate.name)) == 0)
{
- pstate->lexptr += strlen (operator_tokens[i].name);
- token = &operator_tokens[i];
+ pstate->lexptr += strlen (candidate.name);
+ token = &candidate;
break;
}
}
static void
rust_lex_tests (void)
{
- int i;
-
/* Set up dummy "parser", so that rust_type works. */
struct parser_state ps (language_def (language_rust), target_gdbarch (),
nullptr, 0, 0, nullptr, 0, nullptr, false);
rust_lex_stringish_test (&parser, "br####\"\\x73tring\"####", "\\x73tring",
BYTESTRING);
- for (i = 0; i < ARRAY_SIZE (identifier_tokens); ++i)
- rust_lex_test_one (&parser, identifier_tokens[i].name,
- identifier_tokens[i].value);
+ for (const auto &candidate : identifier_tokens)
+ rust_lex_test_one (&parser, candidate.name, candidate.value);
- for (i = 0; i < ARRAY_SIZE (operator_tokens); ++i)
- rust_lex_test_one (&parser, operator_tokens[i].name,
- operator_tokens[i].value);
+ for (const auto &candidate : operator_tokens)
+ rust_lex_test_one (&parser, candidate.name, candidate.value);
rust_lex_test_completion (&parser);
rust_lex_test_push_back (&parser);
"ARM/Thumb C/C++ Compiler, RVCT",
"ARM C/C++ Compiler, RVCT"
};
- int i;
if (producer == NULL)
return false;
- for (i = 0; i < ARRAY_SIZE (arm_idents); i++)
- if (startswith (producer, arm_idents[i]))
+ for (const char *ident : arm_idents)
+ if (startswith (producer, ident))
return true;
return false;