aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-09-26 16:38:02 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-10-29 16:44:45 -0400
commit970db5186051c051d9c5bd1f7ed404902b96fa80 (patch)
treeec3f149b291e22c532b6b61367fd9b2abcdff0e4
parentb610c04548a39dbce6d51c33d7a8125e59066939 (diff)
downloadfsf-binutils-gdb-970db5186051c051d9c5bd1f7ed404902b96fa80.zip
fsf-binutils-gdb-970db5186051c051d9c5bd1f7ed404902b96fa80.tar.gz
fsf-binutils-gdb-970db5186051c051d9c5bd1f7ed404902b96fa80.tar.bz2
gdb: remove TYPE_FIELD_ENUMVAL
Remove TYPE_FIELD_ENUMVAL, replace with type::field + field::loc_enumval. Change-Id: I2ada73e4635aad3363ce2eb22c1dc52698ee2072
-rw-r--r--gdb/ada-lang.c10
-rw-r--r--gdb/ada-typeprint.c6
-rw-r--r--gdb/ada-valprint.c6
-rw-r--r--gdb/c-typeprint.c6
-rw-r--r--gdb/compile/compile-c-types.c2
-rw-r--r--gdb/compile/compile-cplus-types.c2
-rw-r--r--gdb/dwarf2/read.c2
-rw-r--r--gdb/gdbtypes.c18
-rw-r--r--gdb/gdbtypes.h1
-rw-r--r--gdb/m2-typeprint.c6
-rw-r--r--gdb/p-typeprint.c6
-rw-r--r--gdb/python/py-type.c2
-rw-r--r--gdb/typeprint.c2
-rw-r--r--gdb/valops.c2
-rw-r--r--gdb/valprint.c6
15 files changed, 38 insertions, 39 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c7837c7..d964dae 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -651,7 +651,7 @@ ada_discrete_type_high_bound (struct type *type)
}
}
case TYPE_CODE_ENUM:
- return TYPE_FIELD_ENUMVAL (type, type->num_fields () - 1);
+ return type->field (type->num_fields () - 1).loc_enumval ();
case TYPE_CODE_BOOL:
return 1;
case TYPE_CODE_CHAR:
@@ -686,7 +686,7 @@ ada_discrete_type_low_bound (struct type *type)
}
}
case TYPE_CODE_ENUM:
- return TYPE_FIELD_ENUMVAL (type, 0);
+ return type->field (0).loc_enumval ();
case TYPE_CODE_BOOL:
return 0;
case TYPE_CODE_CHAR:
@@ -4617,7 +4617,7 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2)
/* All enums in the type should have an identical underlying value. */
for (i = 0; i < type1->num_fields (); i++)
- if (TYPE_FIELD_ENUMVAL (type1, i) != TYPE_FIELD_ENUMVAL (type2, i))
+ if (type1->field (i).loc_enumval () != type2->field (i).loc_enumval ())
return 0;
/* All enumerals should also have the same name (modulo any numerical
@@ -8578,7 +8578,7 @@ val_atr (struct type *type, LONGEST val)
{
if (val < 0 || val >= type->num_fields ())
error (_("argument to 'VAL out of range"));
- val = TYPE_FIELD_ENUMVAL (type, val);
+ val = type->field (val).loc_enumval ();
}
return value_from_longest (type, val);
}
@@ -10214,7 +10214,7 @@ convert_char_literal (struct type *type, LONGEST val)
size_t elen = strlen (ename);
if (elen >= len && strcmp (name, ename + elen - len) == 0)
- return TYPE_FIELD_ENUMVAL (type, f);
+ return type->field (f).loc_enumval ();
}
return val;
}
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 6bc8912..e336e03 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -328,11 +328,11 @@ print_enum_type (struct type *type, struct ui_file *stream)
wrap_here (" ");
fputs_styled (ada_enum_name (type->field (i).name ()),
variable_name_style.style (), stream);
- if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+ if (lastval != type->field (i).loc_enumval ())
{
fprintf_filtered (stream, " => %s",
- plongest (TYPE_FIELD_ENUMVAL (type, i)));
- lastval = TYPE_FIELD_ENUMVAL (type, i);
+ plongest (type->field (i).loc_enumval ()));
+ lastval = type->field (i).loc_enumval ();
}
lastval += 1;
}
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 04f1c7d..6813af5 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -94,7 +94,7 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
case TYPE_CODE_ENUM:
if (low_bound == 0)
return 0;
- low_bound = TYPE_FIELD_ENUMVAL (index_type, low_bound);
+ low_bound = index_type->field (low_bound).loc_enumval ();
break;
case TYPE_CODE_UNDEF:
index_type = NULL;
@@ -381,7 +381,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
len = type->num_fields ();
for (i = 0; i < len; i++)
{
- if (TYPE_FIELD_ENUMVAL (type, i) == val)
+ if (type->field (i).loc_enumval () == val)
{
break;
}
@@ -835,7 +835,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
for (i = 0; i < len; i++)
{
QUIT;
- if (val == TYPE_FIELD_ENUMVAL (type, i))
+ if (val == type->field (i).loc_enumval ())
break;
}
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index a471fdc..5f20233 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1596,11 +1596,11 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
wrap_here (" ");
fputs_styled (type->field (i).name (),
variable_name_style.style (), stream);
- if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+ if (lastval != type->field (i).loc_enumval ())
{
fprintf_filtered (stream, " = %s",
- plongest (TYPE_FIELD_ENUMVAL (type, i)));
- lastval = TYPE_FIELD_ENUMVAL (type, i);
+ plongest (type->field (i).loc_enumval ()));
+ lastval = type->field (i).loc_enumval ();
}
lastval++;
}
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 8fbbc0e..87eb970 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -137,7 +137,7 @@ convert_enum (compile_c_instance *context, struct type *type)
for (i = 0; i < type->num_fields (); ++i)
{
context->plugin ().build_add_enum_constant
- (result, type->field (i).name (), TYPE_FIELD_ENUMVAL (type, i));
+ (result, type->field (i).name (), type->field (i).loc_enumval ());
}
context->plugin ().finish_enum_type (result);
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index a54a544..1bd083d 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -944,7 +944,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
continue;
instance->plugin ().build_enum_constant (result, fname.get (),
- TYPE_FIELD_ENUMVAL (type, i));
+ type->field (i).loc_enumval ());
}
/* Finish enum definition and pop scopes. */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e3609ab..48fb55c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9201,7 +9201,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
{
const char *name
= rust_last_path_segment (enum_type->field (i).name ());
- discriminant_map[name] = TYPE_FIELD_ENUMVAL (enum_type, i);
+ discriminant_map[name] = enum_type->field (i).loc_enumval ();
}
}
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 0dd2790..84e987b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1068,12 +1068,12 @@ get_discrete_low_bound (struct type *type)
{
/* The enums may not be sorted by value, so search all
entries. */
- LONGEST low = TYPE_FIELD_ENUMVAL (type, 0);
+ LONGEST low = type->field (0).loc_enumval ();
for (int i = 0; i < type->num_fields (); i++)
{
- if (TYPE_FIELD_ENUMVAL (type, i) < low)
- low = TYPE_FIELD_ENUMVAL (type, i);
+ if (type->field (i).loc_enumval () < low)
+ low = type->field (i).loc_enumval ();
}
/* Set unsigned indicator if warranted. */
@@ -1139,12 +1139,12 @@ get_discrete_high_bound (struct type *type)
{
/* The enums may not be sorted by value, so search all
entries. */
- LONGEST high = TYPE_FIELD_ENUMVAL (type, 0);
+ LONGEST high = type->field (0).loc_enumval ();
for (int i = 0; i < type->num_fields (); i++)
{
- if (TYPE_FIELD_ENUMVAL (type, i) > high)
- high = TYPE_FIELD_ENUMVAL (type, i);
+ if (type->field (i).loc_enumval () > high)
+ high = type->field (i).loc_enumval ();
}
return high;
@@ -1250,7 +1250,7 @@ discrete_position (struct type *type, LONGEST val)
for (i = 0; i < type->num_fields (); i += 1)
{
- if (val == TYPE_FIELD_ENUMVAL (type, i))
+ if (val == type->field (i).loc_enumval ())
return i;
}
@@ -5337,7 +5337,7 @@ recursive_dump_type (struct type *type, int spaces)
{
if (type->code () == TYPE_CODE_ENUM)
printf_filtered ("%*s[%d] enumval %s type ", spaces + 2, "",
- idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
+ idx, plongest (type->field (idx).loc_enumval ()));
else
printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
idx, plongest (type->field (idx).loc_bitpos ()),
@@ -5565,7 +5565,7 @@ copy_type_recursive (struct objfile *objfile,
new_type->field (i).set_loc_bitpos (type->field (i).loc_bitpos ());
break;
case FIELD_LOC_KIND_ENUMVAL:
- new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i));
+ new_type->field (i).set_loc_enumval (type->field (i).loc_enumval ());
break;
case FIELD_LOC_KIND_PHYSADDR:
new_type->field (i).set_loc_physaddr
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 18f856f..e6384b1 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2128,7 +2128,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
-#define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
#define TYPE_FIELD_DWARF_BLOCK(thistype, n) ((thistype)->field (n).loc_dwarf_block ())
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index 8209686..c4504e7 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -611,11 +611,11 @@ m2_enum (struct type *type, struct ui_file *stream, int show, int level)
wrap_here (" ");
fputs_styled (type->field (i).name (),
variable_name_style.style (), stream);
- if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+ if (lastval != type->field (i).loc_enumval ())
{
fprintf_filtered (stream, " = %s",
- plongest (TYPE_FIELD_ENUMVAL (type, i)));
- lastval = TYPE_FIELD_ENUMVAL (type, i);
+ plongest (type->field (i).loc_enumval ()));
+ lastval = type->field (i).loc_enumval ();
}
lastval++;
}
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 48bfba8..b2d167f 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -711,12 +711,12 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
fprintf_filtered (stream, ", ");
wrap_here (" ");
fputs_filtered (type->field (i).name (), stream);
- if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+ if (lastval != type->field (i).loc_enumval ())
{
fprintf_filtered (stream,
" := %s",
- plongest (TYPE_FIELD_ENUMVAL (type, i)));
- lastval = TYPE_FIELD_ENUMVAL (type, i);
+ plongest (type->field (i).loc_enumval ()));
+ lastval = type->field (i).loc_enumval ();
}
lastval++;
}
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 0895093..8b17b70 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -184,7 +184,7 @@ convert_field (struct type *type, int field)
if (type->code () == TYPE_CODE_ENUM)
{
- arg = gdb_py_object_from_longest (TYPE_FIELD_ENUMVAL (type, field));
+ arg = gdb_py_object_from_longest (type->field (field).loc_enumval ());
attrstring = "enumval";
}
else
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 097fb68..1312111 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -626,7 +626,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
len = type->num_fields ();
for (i = 0; i < len; i++)
{
- if (TYPE_FIELD_ENUMVAL (type, i) == val)
+ if (type->field (i).loc_enumval () == val)
{
break;
}
diff --git a/gdb/valops.c b/gdb/valops.c
index 0d02584..9787cdb 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3343,7 +3343,7 @@ enum_constant_from_type (struct type *type, const char *name)
&& fname[len - name_len - 2] == ':'
&& fname[len - name_len - 1] == ':'
&& strcmp (&fname[len - name_len], name) == 0)
- return value_from_longest (type, TYPE_FIELD_ENUMVAL (type, i));
+ return value_from_longest (type, type->field (i).loc_enumval ());
}
error (_("no constant named \"%s\" in enum \"%s\""),
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 2656d0d..4230dce 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -608,7 +608,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
for (i = 0; i < len; i++)
{
QUIT;
- if (val == TYPE_FIELD_ENUMVAL (type, i))
+ if (val == type->field (i).loc_enumval ())
{
break;
}
@@ -630,7 +630,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
{
QUIT;
- ULONGEST enumval = TYPE_FIELD_ENUMVAL (type, i);
+ ULONGEST enumval = type->field (i).loc_enumval ();
int nbits = count_one_bits_ll (enumval);
gdb_assert (nbits == 0 || nbits == 1);
@@ -645,7 +645,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
else
fputs_filtered (" | ", stream);
- val &= ~TYPE_FIELD_ENUMVAL (type, i);
+ val &= ~type->field (i).loc_enumval ();
fputs_styled (type->field (i).name (),
variable_name_style.style (), stream);
}