aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.cc
diff options
context:
space:
mode:
authorQing Zhao <qing.zhao@oracle.com>2022-11-09 15:48:04 +0000
committerQing Zhao <qing.zhao@oracle.com>2022-11-09 15:48:04 +0000
commitace0ae09332bbc6b95e084c2c2b17c466339ff76 (patch)
tree54cd5d03b2e32bf70487ddea4dbdccbce7dc28c9 /gcc/tree.cc
parent0b3d926d796050468b8a844e5fb8c20bda741c26 (diff)
downloadgcc-ace0ae09332bbc6b95e084c2c2b17c466339ff76.zip
gcc-ace0ae09332bbc6b95e084c2c2b17c466339ff76.tar.gz
gcc-ace0ae09332bbc6b95e084c2c2b17c466339ff76.tar.bz2
Change the name of array_at_struct_end_p to array_ref_flexible_size_p
The name of the utility routine "array_at_struct_end_p" is misleading and should be changed to a new name that more accurately reflects its real meaning. The routine "array_at_struct_end_p" is used to check whether an array reference is to an array whose actual size might be larger than its upper bound implies, which includes 3 different cases: A. a ref to a flexible array member at the end of a structure; B. a ref to an array with a different type against the original decl; C. a ref to an array that was passed as a parameter; The old name only reflects the above case A, therefore very confusing when reading the corresponding gcc source code. In this patch, A new name "array_ref_flexible_size_p" is used to replace the old name. All the references to the routine "array_at_struct_end_p" was replaced with this new name, and the corresponding comments were updated to make them clean and consistent. gcc/ChangeLog: * gimple-array-bounds.cc (trailing_array): Replace array_at_struct_end_p with new name and update comments. * gimple-fold.cc (get_range_strlen_tree): Likewise. * gimple-ssa-warn-restrict.cc (builtin_memref::builtin_memref): Likewise. * graphite-sese-to-poly.cc (bounds_are_valid): Likewise. * tree-if-conv.cc (idx_within_array_bound): Likewise. * tree-object-size.cc (addr_object_size): Likewise. * tree-ssa-alias.cc (component_ref_to_zero_sized_trailing_array_p): Likewise. (stmt_kills_ref_p): Likewise. * tree-ssa-loop-niter.cc (idx_infer_loop_bounds): Likewise. * tree-ssa-strlen.cc (maybe_set_strlen_range): Likewise. * tree.cc (array_at_struct_end_p): Rename to ... (array_ref_flexible_size_p): ... this. (component_ref_size): Replace array_at_struct_end_p with new name. * tree.h (array_at_struct_end_p): Rename to ... (array_ref_flexible_size_p): ... this.
Diffstat (limited to 'gcc/tree.cc')
-rw-r--r--gcc/tree.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 1720987..574bd2e 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -12727,8 +12727,8 @@ array_ref_up_bound (tree exp)
return NULL_TREE;
}
-/* Returns true if REF is an array reference, component reference,
- or memory reference to an array whose actual size might be larger
+/* Returns true if REF is an array reference, a component reference,
+ or a memory reference to an array whose actual size might be larger
than its upper bound implies, there are multiple cases:
A. a ref to a flexible array member at the end of a structure;
B. a ref to an array with a different type against the original decl;
@@ -12743,10 +12743,10 @@ array_ref_up_bound (tree exp)
int test (uint8_t *p, uint32_t t[1][1], int n) {
for (int i = 0; i < 4; i++, p++)
t[i][0] = ...;
+*/
- FIXME, the name of this routine need to be changed to be more accurate. */
bool
-array_at_struct_end_p (tree ref)
+array_ref_flexible_size_p (tree ref)
{
/* the TYPE for this array referece. */
tree atype = NULL_TREE;
@@ -12879,6 +12879,7 @@ array_at_struct_end_p (tree ref)
return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
}
+
/* Return a tree representing the offset, in bytes, of the field referenced
by EXP. This does not include any offset in DECL_FIELD_BIT_OFFSET. */
@@ -12974,7 +12975,7 @@ component_ref_size (tree ref, special_array_member *sam /* = NULL */)
return (tree_int_cst_equal (memsize, TYPE_SIZE_UNIT (memtype))
? memsize : NULL_TREE);
- bool trailing = array_at_struct_end_p (ref);
+ bool trailing = array_ref_flexible_size_p (ref);
bool zero_length = integer_zerop (memsize);
if (!trailing && !zero_length)
/* MEMBER is either an interior array or is an array with