[review] Move type_byte_order earlier

Message ID gerrit.1574880479000.I4666431ecbb32ec98918f39f72d22c86b2bc8dde@gnutoolchain-gerrit.osci.io
State New, archived
Headers

Commit Message

Simon Marchi (Code Review) Nov. 27, 2019, 6:48 p.m. UTC
  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 (Code Review) Nov. 27, 2019, 10:05 p.m. UTC | #1
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 (Code Review) Dec. 4, 2019, 3:32 p.m. UTC | #2
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
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 66afaea..876a027 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index ff89009..31bfa47 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -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;
-}