diff options
author | Martin Sebor <msebor@redhat.com> | 2021-07-28 15:28:10 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-07-28 16:02:17 -0600 |
commit | 2a837de28ee94b4ec201059a9a7aaa852e6808da (patch) | |
tree | 69c62e5581139c45d20f695344749058b7ae0978 /gcc/gimple-ssa-warn-access.h | |
parent | f471739e636734c2b4933cc4cb4ebad6cb2083ad (diff) | |
download | gcc-2a837de28ee94b4ec201059a9a7aaa852e6808da.zip gcc-2a837de28ee94b4ec201059a9a7aaa852e6808da.tar.gz gcc-2a837de28ee94b4ec201059a9a7aaa852e6808da.tar.bz2 |
Add new gimple-ssa-warn-access pass.
gcc/ChangeLog:
* Makefile.in (OBJS): Add gimple-ssa-warn-access.o and pointer-query.o.
* attribs.h (fndecl_dealloc_argno): Move fndecl_dealloc_argno to tree.h.
* builtins.c (compute_objsize_r): Move to pointer-query.cc.
(access_ref::access_ref): Same.
(access_ref::phi): Same.
(access_ref::get_ref): Same.
(access_ref::size_remaining): Same.
(access_ref::offset_in_range): Same.
(access_ref::add_offset): Same.
(access_ref::inform_access): Same.
(ssa_name_limit_t::visit_phi): Same.
(ssa_name_limit_t::leave_phi): Same.
(ssa_name_limit_t::next): Same.
(ssa_name_limit_t::next_phi): Same.
(ssa_name_limit_t::~ssa_name_limit_t): Same.
(pointer_query::pointer_query): Same.
(pointer_query::get_ref): Same.
(pointer_query::put_ref): Same.
(pointer_query::flush_cache): Same.
(warn_string_no_nul): Move to gimple-ssa-warn-access.cc.
(check_nul_terminated_array): Same.
(unterminated_array): Same.
(maybe_warn_for_bound): Same.
(check_read_access): Same.
(warn_for_access): Same.
(get_size_range): Same.
(check_access): Same.
(gimple_call_alloc_size): Move to tree.c.
(gimple_parm_array_size): Move to pointer-query.cc.
(get_offset_range): Same.
(gimple_call_return_array): Same.
(handle_min_max_size): Same.
(handle_array_ref): Same.
(handle_mem_ref): Same.
(compute_objsize): Same.
(gimple_call_alloc_p): Move to gimple-ssa-warn-access.cc.
(call_dealloc_argno): Same.
(fndecl_dealloc_argno): Same.
(new_delete_mismatch_p): Same.
(matching_alloc_calls_p): Same.
(warn_dealloc_offset): Same.
(maybe_emit_free_warning): Same.
* builtins.h (check_nul_terminated_array): Move to
gimple-ssa-warn-access.h.
(check_nul_terminated_array): Same.
(warn_string_no_nul): Same.
(unterminated_array): Same.
(class ssa_name_limit_t): Same.
(class pointer_query): Same.
(struct access_ref): Same.
(class range_query): Same.
(struct access_data): Same.
(gimple_call_alloc_size): Same.
(gimple_parm_array_size): Same.
(compute_objsize): Same.
(class access_data): Same.
(maybe_emit_free_warning): Same.
* calls.c (initialize_argument_information): Remove call to
maybe_emit_free_warning.
* gimple-array-bounds.cc: Include new header..
* gimple-fold.c: Same.
* gimple-ssa-sprintf.c: Same.
* gimple-ssa-warn-restrict.c: Same.
* passes.def: Add pass_warn_access.
* tree-pass.h (make_pass_warn_access): Declare.
* tree-ssa-strlen.c: Include new headers.
* tree.c (fndecl_dealloc_argno): Move here from builtins.c.
* tree.h (fndecl_dealloc_argno): Move here from attribs.h.
* gimple-ssa-warn-access.cc: New file.
* gimple-ssa-warn-access.h: New file.
* pointer-query.cc: New file.
* pointer-query.h: New file.
gcc/cp/ChangeLog:
* init.c: Include new header.
Diffstat (limited to 'gcc/gimple-ssa-warn-access.h')
-rw-r--r-- | gcc/gimple-ssa-warn-access.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/gimple-ssa-warn-access.h b/gcc/gimple-ssa-warn-access.h new file mode 100644 index 0000000..6197574 --- /dev/null +++ b/gcc/gimple-ssa-warn-access.h @@ -0,0 +1,37 @@ +/* Pass to detect and issue warnings for invalid accesses, including + invalid or mismatched allocation/deallocation calls. + + Copyright (C) 2020-2021 Free Software Foundation, Inc. + Contributed by Martin Sebor <msebor@redhat.com>. + + 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/>. */ + +#ifndef GCC_GIMPLE_SSA_WARN_ACCESS_H +#define GCC_GIMPLE_SSA_WARN_ACCESS_H + +extern bool check_nul_terminated_array (tree, tree, tree = NULL_TREE); +extern void warn_string_no_nul (location_t, tree, const char *, tree, + tree, tree = NULL_TREE, bool = false, + const wide_int[2] = NULL); +extern tree unterminated_array (tree, tree * = NULL, bool * = NULL); +extern void get_size_range (tree, tree[2], const offset_int[2]); + +class access_data; +extern bool maybe_warn_for_bound (opt_code, location_t, tree, tree, + tree[2], tree, const access_data * = NULL); + +#endif // GCC_GIMPLE_SSA_WARN_ACCESS_H |