diff options
author | David Malcolm <dmalcolm@redhat.com> | 2022-11-16 08:23:02 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2022-11-16 08:23:02 -0500 |
commit | 21501ec751c102ce06ff3483375eb922c5c9cee3 (patch) | |
tree | 0f45bb9fc21e68aed8356683b6ce1fd5b418c0b3 /gcc/analyzer/sm-fd.cc | |
parent | 3685aed8ef34b7bb500cf92b5913a4092d6f55be (diff) | |
download | gcc-21501ec751c102ce06ff3483375eb922c5c9cee3.zip gcc-21501ec751c102ce06ff3483375eb922c5c9cee3.tar.gz gcc-21501ec751c102ce06ff3483375eb922c5c9cee3.tar.bz2 |
analyzer: use known_function to simplify region_model::on_call_{pre,post}
Replace lots of repeated checks against strings with a hash_map lookup.
Add some missing type-checking for handling known functions (e.g. checks
for pointer types).
gcc/analyzer/ChangeLog:
* analyzer.h (known_function::matches_call_types_p): New vfunc.
(known_function::impl_call_pre): Provide base implementation.
(known_function::impl_call_post): New vfunc.
(register_known_functions): New.
* engine.cc (impl_run_checkers): Call register_known_functions.
* region-model-impl-calls.cc (region_model::impl_call_accept):
Convert to...
(class known_function_accept): ...this.
(region_model::impl_call_bind): Convert to...
(class known_function_bind): ...this.
(region_model::impl_call_connect): Convert to...
(class known_function_connect): ...this.
(region_model::impl_call_listen): Convert to...
(class known_function_listen): ...this.
(region_model::impl_call_socket): Convert to...
(class known_function_socket): ...this.
(register_known_functions): New.
* region-model.cc (region_model::on_call_pre): Remove special
case for "bind" in favor of the known_function-handling dispatch.
Add call to known_function::matches_call_types_p to latter.
(region_model::on_call_post): Remove special cases for "accept",
"bind", "connect", "listen", and "socket" in favor of dispatch
to known_function::impl_call_post.
* region-model.h (region_model::impl_call_accept): Delete decl.
(region_model::impl_call_bind): Delete decl.
(region_model::impl_call_connect): Delete decl.
(region_model::impl_call_listen): Delete decl.
(region_model::impl_call_socket): Delete decl.
* sm-fd.cc: Update comments.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_kernel_plugin.c
(copy_across_boundary_fn::matches_call_types_p): New.
* gcc.dg/plugin/analyzer_known_fns_plugin.c
(known_function_returns_42::matches_call_types_p): New.
(known_function_attempt_to_copy::matches_call_types_p): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/sm-fd.cc')
-rw-r--r-- | gcc/analyzer/sm-fd.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc index d0b5871..1f479b6 100644 --- a/gcc/analyzer/sm-fd.cc +++ b/gcc/analyzer/sm-fd.cc @@ -2249,7 +2249,7 @@ region_model::mark_as_valid_fd (const svalue *sval, region_model_context *ctxt) } /* Specialcase hook for handling "socket", for use by - region_model::impl_call_socket::outcome_of_socket::update_model. */ + known_function_socket::outcome_of_socket::update_model. */ bool region_model::on_socket (const call_details &cd, bool successful) @@ -2267,7 +2267,7 @@ region_model::on_socket (const call_details &cd, bool successful) } /* Specialcase hook for handling "bind", for use by - region_model::impl_call_bind::outcome_of_bind::update_model. */ + known_function_bind::outcome_of_bind::update_model. */ bool region_model::on_bind (const call_details &cd, bool successful) @@ -2285,7 +2285,7 @@ region_model::on_bind (const call_details &cd, bool successful) } /* Specialcase hook for handling "listen", for use by - region_model::impl_call_listen::outcome_of_listen::update_model. */ + known_function_listen::outcome_of_listen::update_model. */ bool region_model::on_listen (const call_details &cd, bool successful) @@ -2303,7 +2303,7 @@ region_model::on_listen (const call_details &cd, bool successful) } /* Specialcase hook for handling "accept", for use by - region_model::impl_call_accept::outcome_of_accept::update_model. */ + known_function_accept::outcome_of_accept::update_model. */ bool region_model::on_accept (const call_details &cd, bool successful) @@ -2321,7 +2321,7 @@ region_model::on_accept (const call_details &cd, bool successful) } /* Specialcase hook for handling "connect", for use by - region_model::impl_call_connect::outcome_of_connect::update_model. */ + known_function_connect::outcome_of_connect::update_model. */ bool region_model::on_connect (const call_details &cd, bool successful) |