aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-12-03 14:45:37 -0700
committerTom Tromey <tom@tromey.com>2021-12-08 13:20:30 -0700
commit696d6f4d5c1bc9b36d0402c2393efe62e49392d9 (patch)
treee0a5c7edfce36b065afc1f443a15906936c44660 /gdb/ada-lang.c
parent621f8c42d3df079ca5781cdb0925c5ec3498f59c (diff)
downloadgdb-696d6f4d5c1bc9b36d0402c2393efe62e49392d9.zip
gdb-696d6f4d5c1bc9b36d0402c2393efe62e49392d9.tar.gz
gdb-696d6f4d5c1bc9b36d0402c2393efe62e49392d9.tar.bz2
Use for-each more in gdb
There are some loops in gdb that use ARRAY_SIZE (or a wordier equivalent) to loop over a static array. This patch changes some of these to use foreach instead. Regression tested on x86-64 Fedora 34.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 336d950..e636c84 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12202,7 +12202,6 @@ static std::string
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;
@@ -12235,9 +12234,9 @@ ada_exception_catchpoint_cond_string (const char *excep_string,
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;
@@ -12467,13 +12466,11 @@ ada_is_exception_sym (struct symbol *sym)
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.
@@ -12538,20 +12535,17 @@ static void
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);
}