Commit 80c2bad6 by Martin Sebor Committed by Jeff Law

gimple-fold.c (get_range_strlen): Minor logic cleanup.

	* gimple-fold.c (get_range_strlen): Minor logic cleanup.  Add comments
	on code's intent.

Co-Authored-By: Jeff Law <law@redhat.com>

From-SVN: r267483
parent 598f7235
2018-12-30 Martin Sebor <msebor@redhat.com> 2018-12-30 Martin Sebor <msebor@redhat.com>
Jeff Law <law@redhat.com> Jeff Law <law@redhat.com>
* gimple-fold.c (get_range_strlen): Minor logic cleanup. Add comments
on code's intent.
* gimple-fold.c (strlen_range_kind): New enum. * gimple-fold.c (strlen_range_kind): New enum.
(get_range_strlen): Update signature to use strlen_range_kind (get_range_strlen): Update signature to use strlen_range_kind
instead of type+fuzzy. instead of type+fuzzy.
...@@ -1548,10 +1548,17 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, ...@@ -1548,10 +1548,17 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited,
if (!get_range_strlen (ops[i], length, visited, rkind, if (!get_range_strlen (ops[i], length, visited, rkind,
flexp, eltsize, nonstr)) flexp, eltsize, nonstr))
{ {
if (rkind == SRK_LENRANGE_2) if (rkind != SRK_LENRANGE_2)
*maxlen = build_all_ones_cst (size_type_node);
else
return false; return false;
/* Set the upper bound to the maximum to prevent
it from being adjusted in the next iteration but
leave MINLEN and the more conservative MAXBOUND
determined so far alone (or leave them null if
they haven't been set yet). That the MINLEN is
in fact zero can be determined from MAXLEN being
unbounded but the discovered minimum is used for
diagnostics. */
*maxlen = build_all_ones_cst (size_type_node);
} }
return true; return true;
} }
...@@ -1576,10 +1583,17 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, ...@@ -1576,10 +1583,17 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited,
if (!get_range_strlen (arg, length, visited, rkind, flexp, if (!get_range_strlen (arg, length, visited, rkind, flexp,
eltsize, nonstr)) eltsize, nonstr))
{ {
if (rkind == SRK_LENRANGE_2) if (rkind != SRK_LENRANGE_2)
*maxlen = build_all_ones_cst (size_type_node);
else
return false; return false;
/* Set the upper bound to the maximum to prevent
it from being adjusted in the next iteration but
leave MINLEN and the more conservative MAXBOUND
determined so far alone (or leave them null if
they haven't been set yet). That the MINLEN is
in fact zero can be determined from MAXLEN being
unbounded but the discovered minimum is used for
diagnostics. */
*maxlen = build_all_ones_cst (size_type_node);
} }
} }
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment