diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-12-09 14:49:02 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2020-12-09 15:36:28 -0500 |
commit | 969da52cb04effd49b937f5f1754e0f4b84809b7 (patch) | |
tree | 398697f89ea2fcea9e669ded3ee9fce3c6583b0d | |
parent | 138084b24811c191a85c919116d839a8bd89d57c (diff) | |
download | gdb-969da52cb04effd49b937f5f1754e0f4b84809b7.zip gdb-969da52cb04effd49b937f5f1754e0f4b84809b7.tar.gz gdb-969da52cb04effd49b937f5f1754e0f4b84809b7.tar.bz2 |
gdb: address review comments of previous series
I forgot to include fixes for review comments I got before pushing the
previous commits (or I pushed the wrong commits). This one fixes it.
- Return {} instead of false in get_discrete_low_bound and
get_discrete_high_bound.
- Compute high bound after confirming low bound is valid in
get_discrete_bounds.
gdb/ChangeLog:
* gdbtypes.c (get_discrete_low_bound, get_discrete_high_bound):
Return {} instead of false.
(get_discrete_bounds): Compute high bound only if low bound is
valid.
Change-Id: I5f9a66b3672adfac9441068c899ab113ab2c331a
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 14 |
2 files changed, 15 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0b08eaf..dd13414 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-12-09 Simon Marchi <simon.marchi@polymtl.ca> + + * gdbtypes.c (get_discrete_low_bound, get_discrete_high_bound): + Return {} instead of false. + (get_discrete_bounds): Compute high bound only if low bound is + valid. + 2020-12-09 Simon Marchi <simon.marchi@efficios.com> PR 26875, PR 26901 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9cd7992..6c1cd08 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1081,7 +1081,7 @@ get_discrete_low_bound (struct type *type) case TYPE_CODE_INT: if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */ - return false; + return {}; if (!TYPE_UNSIGNED (type)) return -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1)); @@ -1091,7 +1091,7 @@ get_discrete_low_bound (struct type *type) return 0; default: - return false; + return {}; } } @@ -1148,7 +1148,7 @@ get_discrete_high_bound (struct type *type) case TYPE_CODE_INT: if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */ - return false; + return {}; if (!TYPE_UNSIGNED (type)) { @@ -1167,7 +1167,7 @@ get_discrete_high_bound (struct type *type) } default: - return false; + return {}; } } @@ -1177,9 +1177,11 @@ bool get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp) { gdb::optional<LONGEST> low = get_discrete_low_bound (type); - gdb::optional<LONGEST> high = get_discrete_high_bound (type); + if (!low.has_value ()) + return false; - if (!low.has_value () || !high.has_value ()) + gdb::optional<LONGEST> high = get_discrete_high_bound (type); + if (!high.has_value ()) return false; *lowp = *low; |