diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-06-01 13:50:32 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-06-01 13:50:32 -0400 |
commit | 2b0a7fe3abfbd47081f714a0a1263afe00c5cfd9 (patch) | |
tree | d6a7d107277c1d8f4fa0c9f008846a704e5a2dba /gcc/analyzer/engine.cc | |
parent | f12454278dc725fec3520a5d870e967d79292ee6 (diff) | |
download | gcc-2b0a7fe3abfbd47081f714a0a1263afe00c5cfd9.zip gcc-2b0a7fe3abfbd47081f714a0a1263afe00c5cfd9.tar.gz gcc-2b0a7fe3abfbd47081f714a0a1263afe00c5cfd9.tar.bz2 |
analyzer: detect -Wanalyzer-allocation-size at call stmts [PR106203]
gcc/analyzer/ChangeLog:
PR analyzer/106203
* checker-event.h: Include "analyzer/event-loc-info.h".
(struct event_loc_info): Move to its own header file.
* diagnostic-manager.cc
(diagnostic_manager::emit_saved_diagnostic): Move creation of
event_loc_info here from add_final_event, and if we have a
stmt_finder, call its update_event_loc_info method.
* engine.cc (leak_stmt_finder::update_event_loc_info): New.
(exploded_node::detect_leaks): Likewise.
(exploded_node::detect_leaks): Pass nullptr as call_stmt arg to
region_model::pop_frame.
* event-loc-info.h: New file, with content taken from
checker-event.h.
* exploded-graph.h (stmt_finder::update_event_loc_info): New pure
virtual function.
* infinite-loop.cc (infinite_loop_diagnostic::add_final_event):
Update for change to vfunc signature.
* infinite-recursion.cc
(infinite_recursion_diagnostic::add_final_event): Likewise.
* pending-diagnostic.cc (pending_diagnostic::add_final_event):
Pass in the event_loc_info from the caller, rather than generating
it from a gimple stmt and enode.
* pending-diagnostic.h (pending_diagnostic::add_final_event):
Likewise.
* region-model.cc (region_model::on_longjmp): Pass nullptr as
call_stmt arg to region_model::pop_frame.
(region_model::update_for_return_gcall): Likewise, but pass
call_stmt.
(class caller_context): New.
(region_model::pop_frame): Add "call_stmt" argument. Use it
and the frame_region with a caller_context when setting
result_dst_reg's value so that any diagnostic is reported at the
call stmt in the caller.
(selftest::test_stack_frames): Pass nullptr as call_stmt arg to
region_model::pop_frame.
(selftest::test_alloca): Likewise.
* region-model.h (region_model::pop_frame): Add "call_stmt"
argument.
gcc/testsuite/ChangeLog:
PR analyzer/106203
* c-c++-common/analyzer/allocation-size-1.c (test_9): Remove
xfail.
* c-c++-common/analyzer/allocation-size-2.c (test_8): Likewise.
* gcc.dg/analyzer/allocation-size-multiline-4.c: New test.
* gcc.dg/plugin/analyzer_cpython_plugin.c
(refcnt_stmt_finder::update_event_loc_info): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/engine.cc')
-rw-r--r-- | gcc/analyzer/engine.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 46d9b80..8b3706c 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -681,6 +681,11 @@ public: return NULL; } + void update_event_loc_info (event_loc_info &) final override + { + /* No-op. */ + } + private: const exploded_graph &m_eg; tree m_var; @@ -2056,7 +2061,7 @@ exploded_node::detect_leaks (exploded_graph &eg) &old_state, &new_state, &uncertainty, NULL, get_stmt ()); const svalue *result = NULL; - new_state.m_region_model->pop_frame (NULL, &result, &ctxt); + new_state.m_region_model->pop_frame (NULL, &result, &ctxt, nullptr); program_state::detect_leaks (old_state, new_state, result, eg.get_ext_state (), &ctxt); } |