diff options
author | Ian Lance Taylor <iant@golang.org> | 2023-06-21 11:04:04 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2023-06-21 11:04:04 -0700 |
commit | 97e31a0a2a2d2273687fcdb4e5416aab1a2186e1 (patch) | |
tree | d5c1cae4de436a0fe54a5f0a2a197d309f3d654c /gcc/gimple-array-bounds.cc | |
parent | 6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced (diff) | |
parent | 577223aebc7acdd31e62b33c1682fe54a622ae27 (diff) | |
download | gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.zip gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.tar.gz gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.tar.bz2 |
Merge from trunk revision 577223aebc7acdd31e62b33c1682fe54a622ae27.
Diffstat (limited to 'gcc/gimple-array-bounds.cc')
-rw-r--r-- | gcc/gimple-array-bounds.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc index 34e039a..e04c8e2 100644 --- a/gcc/gimple-array-bounds.cc +++ b/gcc/gimple-array-bounds.cc @@ -46,10 +46,12 @@ array_bounds_checker::array_bounds_checker (struct function *func, /* No-op. */ } -const value_range * -array_bounds_checker::get_value_range (const_tree op, gimple *stmt) +void +array_bounds_checker::get_value_range (irange &r, const_tree op, gimple *stmt) { - return m_ptr_qry.rvals->get_value_range (op, stmt); + if (m_ptr_qry.rvals->range_of_expr (r, const_cast<tree> (op), stmt)) + return; + r.set_varying (TREE_TYPE (op)); } /* Try to determine the DECL that REF refers to. Return the DECL or @@ -264,6 +266,7 @@ check_out_of_bounds_and_warn (location_t location, tree ref, bool ignore_off_by_one, bool for_array_bound, bool *out_of_bound) { + tree min, max; tree low_bound = array_ref_low_bound (ref); tree artype = TREE_TYPE (TREE_OPERAND (ref, 0)); @@ -282,7 +285,7 @@ check_out_of_bounds_and_warn (location_t location, tree ref, if (warned) ; /* Do nothing. */ - else if (vr && vr->kind () == VR_ANTI_RANGE) + else if (get_legacy_range (*vr, min, max) == VR_ANTI_RANGE) { if (up_bound && TREE_CODE (up_sub) == INTEGER_CST @@ -370,20 +373,22 @@ array_bounds_checker::check_array_ref (location_t location, tree ref, tree up_sub = low_sub_org; tree low_sub = low_sub_org; - const value_range *vr = NULL; + value_range vr; if (TREE_CODE (low_sub_org) == SSA_NAME) { - vr = get_value_range (low_sub_org, stmt); - if (!vr->undefined_p () && !vr->varying_p ()) + get_value_range (vr, low_sub_org, stmt); + if (!vr.undefined_p () && !vr.varying_p ()) { - low_sub = vr->kind () == VR_RANGE ? vr->max () : vr->min (); - up_sub = vr->kind () == VR_RANGE ? vr->min () : vr->max (); + tree min, max; + value_range_kind kind = get_legacy_range (vr, min, max); + low_sub = kind == VR_RANGE ? max : min; + up_sub = kind == VR_RANGE ? min : max; } } warned = check_out_of_bounds_and_warn (location, ref, low_sub_org, low_sub, up_sub, - up_bound, up_bound_p1, vr, + up_bound, up_bound_p1, &vr, ignore_off_by_one, warn_array_bounds, &out_of_bound); |