[review] Move type_byte_order earlier
Commit Message
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/728
......................................................................
Move type_byte_order earlier
I failed to notice that the scalar_storage_order patch put
type_byte_order at the end of gdbtypes.c. The end of the file is
normally where the file's _initialize function goes. This moves
type_byte_order earlier, into a more relevant section.
gdb/ChangeLog
2019-11-27 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (type_byte_order): Move earlier.
Change-Id: I4666431ecbb32ec98918f39f72d22c86b2bc8dde
---
M gdb/ChangeLog
M gdb/gdbtypes.c
2 files changed, 22 insertions(+), 18 deletions(-)
Comments
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/728
......................................................................
Patch Set 1:
(2 comments)
| --- gdb/gdbtypes.c
| +++ gdb/gdbtypes.c
| @@ -3344,12 +3344,30 @@ is_unique_ancestor (struct type *base, struct value *val)
| int offset = -1;
|
| return is_unique_ancestor_worker (base, value_type (val), &offset,
| value_contents_for_printing (val),
| value_embedded_offset (val),
| value_address (val), val) == 1;
| }
|
| +/* See gdbtypes.h. */
| +enum bfd_endian
PS1, Line 3353:
Might as well add a newline between the comment and the return type.
| +type_byte_order (const struct type *type)
| +{
| + bfd_endian byteorder = gdbarch_byte_order (get_type_arch (type));
| + if (TYPE_ENDIANITY_NOT_DEFAULT (type))
| + {
| + if (byteorder == BFD_ENDIAN_BIG)
| + return BFD_ENDIAN_LITTLE;
| + else if (byteorder == BFD_ENDIAN_LITTLE)
| + return BFD_ENDIAN_BIG;
| + else
| + return BFD_ENDIAN_UNKNOWN;
PS1, Line 3364:
Also not related to this patch, but is there really a legitimate case
for this else (byteorder being not _BIG and not _LITTLE)? Sounds to
me like this should be an assert.
| + }
| +
| + return byteorder;
| +}
| +
|
| /* Overload resolution. */
|
| /* Return the sum of the rank of A with the rank of B. */
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/728
......................................................................
Patch Set 2: Code-Review+2
@@ -1,5 +1,9 @@
2019-11-27 Tom Tromey <tromey@adacore.com>
+ * gdbtypes.c (type_byte_order): Move earlier.
+
+2019-11-27 Tom Tromey <tromey@adacore.com>
+
* dwarf2read.c (dwarf2_init_float_type)
(dwarf2_init_complex_target_type): Add byte_order parameter.
(read_base_type): Compute byte order earlier.
@@ -3349,6 +3349,24 @@
value_address (val), val) == 1;
}
+/* See gdbtypes.h. */
+enum bfd_endian
+type_byte_order (const struct type *type)
+{
+ bfd_endian byteorder = gdbarch_byte_order (get_type_arch (type));
+ if (TYPE_ENDIANITY_NOT_DEFAULT (type))
+ {
+ if (byteorder == BFD_ENDIAN_BIG)
+ return BFD_ENDIAN_LITTLE;
+ else if (byteorder == BFD_ENDIAN_LITTLE)
+ return BFD_ENDIAN_BIG;
+ else
+ return BFD_ENDIAN_UNKNOWN;
+ }
+
+ return byteorder;
+}
+
/* Overload resolution. */
@@ -5627,21 +5645,3 @@
show_strict_type_checking,
&setchecklist, &showchecklist);
}
-
-/* See gdbtypes.h. */
-enum bfd_endian
-type_byte_order (const struct type *type)
-{
- bfd_endian byteorder = gdbarch_byte_order (get_type_arch (type));
- if (TYPE_ENDIANITY_NOT_DEFAULT (type))
- {
- if (byteorder == BFD_ENDIAN_BIG)
- return BFD_ENDIAN_LITTLE;
- else if (byteorder == BFD_ENDIAN_LITTLE)
- return BFD_ENDIAN_BIG;
- else
- return BFD_ENDIAN_UNKNOWN;
- }
-
- return byteorder;
-}