diff mbox series

[058/nnn] poly_int: get_binfo_at_offset

Message ID 87wp3lkcaj.fsf@linaro.org
State New
Headers show
Series [058/nnn] poly_int: get_binfo_at_offset | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 5:24 p.m. UTC
This patch changes the offset parameter to get_binfo_at_offset
from HOST_WIDE_INT to poly_int64.  This function probably doesn't
need to handle polynomial offsets in practice, but it's easy
to do and avoids forcing the caller to check first.


2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* tree.h (get_binfo_at_offset): Take the offset as a poly_int64
	rather than a HOST_WIDE_INT.
	* tree.c (get_binfo_at_offset): Likewise.

Comments

Jeff Law Nov. 28, 2017, 4:48 p.m. UTC | #1
On 10/23/2017 11:24 AM, Richard Sandiford wrote:
> This patch changes the offset parameter to get_binfo_at_offset

> from HOST_WIDE_INT to poly_int64.  This function probably doesn't

> need to handle polynomial offsets in practice, but it's easy

> to do and avoids forcing the caller to check first.

> 

> 

> 2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>

> 	    Alan Hayward  <alan.hayward@arm.com>

> 	    David Sherwood  <david.sherwood@arm.com>

> 

> gcc/

> 	* tree.h (get_binfo_at_offset): Take the offset as a poly_int64

> 	rather than a HOST_WIDE_INT.

> 	* tree.c (get_binfo_at_offset): Likewise.

>

OK.
jeff
diff mbox series

Patch

Index: gcc/tree.h
===================================================================
--- gcc/tree.h	2017-10-23 17:20:50.884679814 +0100
+++ gcc/tree.h	2017-10-23 17:22:21.308442966 +0100
@@ -4836,7 +4836,7 @@  extern void tree_set_block (tree, tree);
 extern location_t *block_nonartificial_location (tree);
 extern location_t tree_nonartificial_location (tree);
 extern tree block_ultimate_origin (const_tree);
-extern tree get_binfo_at_offset (tree, HOST_WIDE_INT, tree);
+extern tree get_binfo_at_offset (tree, poly_int64, tree);
 extern bool virtual_method_call_p (const_tree);
 extern tree obj_type_ref_class (const_tree ref);
 extern bool types_same_for_odr (const_tree type1, const_tree type2,
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	2017-10-23 17:22:18.236826658 +0100
+++ gcc/tree.c	2017-10-23 17:22:21.307442765 +0100
@@ -12328,7 +12328,7 @@  lookup_binfo_at_offset (tree binfo, tree
    found, return, otherwise return NULL_TREE.  */
 
 tree
-get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type)
+get_binfo_at_offset (tree binfo, poly_int64 offset, tree expected_type)
 {
   tree type = BINFO_TYPE (binfo);
 
@@ -12340,7 +12340,7 @@  get_binfo_at_offset (tree binfo, HOST_WI
 
       if (types_same_for_odr (type, expected_type))
 	  return binfo;
-      if (offset < 0)
+      if (may_lt (offset, 0))
 	return NULL_TREE;
 
       for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
@@ -12350,7 +12350,7 @@  get_binfo_at_offset (tree binfo, HOST_WI
 
 	  pos = int_bit_position (fld);
 	  size = tree_to_uhwi (DECL_SIZE (fld));
-	  if (pos <= offset && (pos + size) > offset)
+	  if (known_in_range_p (offset, pos, size))
 	    break;
 	}
       if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE)
@@ -12358,7 +12358,7 @@  get_binfo_at_offset (tree binfo, HOST_WI
 
       /* Offset 0 indicates the primary base, whose vtable contents are
 	 represented in the binfo for the derived class.  */
-      else if (offset != 0)
+      else if (maybe_nonzero (offset))
 	{
 	  tree found_binfo = NULL, base_binfo;
 	  /* Offsets in BINFO are in bytes relative to the whole structure