GCC Middle and Back End API Reference
|
#include <gimple-array-bounds.h>
Public Member Functions | |
array_bounds_checker (struct function *, range_query *) | |
void | check () |
Private Member Functions | |
bool | check_array_ref (location_t, tree, gimple *, bool ignore_off_by_one) |
bool | check_mem_ref (location_t, tree, bool ignore_off_by_one) |
void | check_addr_expr (location_t, tree, gimple *) |
void | get_value_range (irange &r, const_tree op, gimple *) |
Static Private Member Functions | |
static tree | check_array_bounds (tree *tp, int *walk_subtree, void *data) |
Private Attributes | |
struct function * | fun |
pointer_query | m_ptr_qry |
gimple * | m_stmt |
Friends | |
class | check_array_bounds_dom_walker |
Array bounds checking. Copyright (C) 2020-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
array_bounds_checker::array_bounds_checker | ( | struct function * | func, |
range_query * | qry ) |
Array bounds checking. Copyright (C) 2005-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
void array_bounds_checker::check | ( | ) |
References ENTRY_BLOCK_PTR_FOR_FN, fun, and ggc_alloc().
|
private |
Searches if the expr T, located at LOCATION computes address of an ARRAY_REF, and call check_array_ref on it.
References check_array_ref(), check_mem_ref(), DECL_P, DECL_SOURCE_LOCATION, dump_file, dump_flags, dump_generic_expr(), ggc_alloc(), handled_component_p(), inform(), mem_ref_offset(), MSG_NOTE, wi::sdiv_trunc(), suppress_warning(), TDF_DETAILS, TDF_SLIM, wi::to_offset(), TREE_CODE, TREE_OPERAND, TREE_TYPE, TYPE_DOMAIN, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_SIZE_UNIT, warning_at(), and warning_suppressed_p().
Referenced by check_array_bounds().
|
staticprivate |
Callback for walk_tree to check a tree for out of bounds array accesses. The array_bounds_checker class is passed in DATA.
References check_addr_expr(), check_array_ref(), check_mem_ref(), EXPR_HAS_LOCATION, EXPR_LOCATION, gcc_assert, ggc_alloc(), gimple_location(), inbounds_memaccess_p(), m_stmt, NULL_TREE, suppress_warning(), and TREE_CODE.
Referenced by check_array_bounds_dom_walker::before_dom_children().
|
private |
Checks one ARRAY_REF in REF, located at LOCUS. Ignores flexible arrays and "struct" hacks. If VRP can determine that the array subscript is a constant, check if it is outside valid range. If the array subscript is a RANGE, warn if it is non-overlapping with valid range. IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR. Return true if a warning has been issued or if no-warning is set.
References array_ref_up_bound(), check_out_of_bounds_and_warn(), component_ref_sam_type(), DECL_NOT_FLEXARRAY, DECL_P, DECL_SOURCE_LOCATION, dump_file, dump_flags, dump_generic_expr(), G_, get_legacy_range(), get_up_bounds_for_array_ref(), get_value_range(), ggc_alloc(), inform(), int_0, MSG_NOTE, NULL_TREE, suppress_warning(), TDF_DETAILS, TDF_SLIM, trail_0, trail_1, trail_n, TREE_CODE, TREE_OPERAND, TREE_TYPE, vrange::undefined_p(), VAR_P, vrange::varying_p(), VR_RANGE, warning_at(), and warning_suppressed_p().
Referenced by check_addr_expr(), and check_array_bounds().
|
private |
Checks one MEM_REF in REF, located at LOCATION, for out-of-bounds references to string constants. If VRP can determine that the array subscript is a constant, check if it is outside valid range. If the array subscript is a RANGE, warn if it is non-overlapping with valid range. IGNORE_OFF_BY_ONE is true if the MEM_REF is inside an ADDR_EXPR (used to allow one-past-the-end indices for code that takes the address of the just-past-the-end element of an array). Returns true if a warning has been issued.
References access_none, build_array_type_nelts(), build_printable_array_type(), pointer_query::get_ref(), ggc_alloc(), i, is_gimple_call(), m_ptr_qry, m_stmt, NULL, POINTER_TYPE_P, SSA_NAME_DEF_STMT, strip_array_types(), suppress_warning(), wi::to_offset(), TREE_CODE, TREE_TYPE, TYPE_SIZE_UNIT, unsigned_char_type_node, warning_at(), and warning_suppressed_p().
Referenced by check_addr_expr(), and check_array_bounds().
|
private |
References m_ptr_qry, r, range_query::range_of_expr(), pointer_query::rvals, and TREE_TYPE.
Referenced by check_array_ref().
|
private |
Referenced by check_mem_ref(), and get_value_range().
|
private |
Referenced by check_array_bounds_dom_walker::before_dom_children(), check_array_bounds(), and check_mem_ref().