diff options
-rw-r--r-- | gdb/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 41 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 20 |
3 files changed, 72 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8f66078450..21b086c9d4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2018-01-24 Pedro Alves <palves@redhat.com> + + GCC PR libstdc++/83906 + * gdbtypes.c (operator==(const dynamic_prop &, + const dynamic_prop &)): New. + (operator==(const range_bounds &, const range_bounds &)): New. + (check_types_equal): Use them instead of memcmp. + * gdbtypes.h (operator==(const dynamic_prop &, + const dynamic_prop &)): Declare. + (operator!=(const dynamic_prop &, const dynamic_prop &)): Declare. + (operator==(const range_bounds &, const range_bounds &)): Declare. + (operator!=(const range_bounds &, const range_bounds &)): Declare. + 2018-01-22 Maciej W. Rozycki <macro@mips.com> * MAINTAINERS: Update my company e-mail address. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 7ba62df474..43fe56e487 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -858,6 +858,44 @@ allocate_stub_method (struct type *type) return mtype; } +/* See gdbtypes.h. */ + +bool +operator== (const dynamic_prop &l, const dynamic_prop &r) +{ + if (l.kind != r.kind) + return false; + + switch (l.kind) + { + case PROP_UNDEFINED: + return true; + case PROP_CONST: + return l.data.const_val == r.data.const_val; + case PROP_ADDR_OFFSET: + case PROP_LOCEXPR: + case PROP_LOCLIST: + return l.data.baton == r.data.baton; + } + + gdb_assert_not_reached ("unhandled dynamic_prop kind"); +} + +/* See gdbtypes.h. */ + +bool +operator== (const range_bounds &l, const range_bounds &r) +{ +#define FIELD_EQ(FIELD) (l.FIELD == r.FIELD) + + return (FIELD_EQ (low) + && FIELD_EQ (high) + && FIELD_EQ (flag_upper_bound_is_count) + && FIELD_EQ (flag_bound_evaluated)); + +#undef FIELD_EQ +} + /* Create a range type with a dynamic range from LOW_BOUND to HIGH_BOUND, inclusive. See create_range_type for further details. */ @@ -3512,8 +3550,7 @@ check_types_equal (struct type *type1, struct type *type2, if (TYPE_CODE (type1) == TYPE_CODE_RANGE) { - if (memcmp (TYPE_RANGE_DATA (type1), TYPE_RANGE_DATA (type2), - sizeof (*TYPE_RANGE_DATA (type1))) != 0) + if (*TYPE_RANGE_DATA (type1) != *TYPE_RANGE_DATA (type2)) return 0; } else diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 5942b5ad48..92ca85c295 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -404,6 +404,16 @@ struct dynamic_prop union dynamic_prop_data data; }; +/* Compare two dynamic_prop objects for equality. dynamic_prop + instances are equal iff they have the same type and storage. */ +extern bool operator== (const dynamic_prop &l, const dynamic_prop &r); + +/* Compare two dynamic_prop objects for inequality. */ +static inline bool operator!= (const dynamic_prop &l, const dynamic_prop &r) +{ + return !(l == r); +} + /* * Define a type's dynamic property node kind. */ enum dynamic_prop_node_kind { @@ -561,6 +571,16 @@ struct range_bounds int flag_bound_evaluated : 1; }; +/* Compare two range_bounds objects for equality. Simply does + memberwise comparison. */ +extern bool operator== (const range_bounds &l, const range_bounds &r); + +/* Compare two range_bounds objects for inequality. */ +static inline bool operator!= (const range_bounds &l, const range_bounds &r) +{ + return !(l == r); +} + union type_specific { /* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to |