analyzer: precision-of-wording for -Wanalyzer-stale-setjmp-buffer
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 12 Nov 2020 02:18:59 +0000 (21:18 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 12 Nov 2020 02:18:59 +0000 (21:18 -0500)
commit8069928d5c2a99973ac16a49d6c25bc4dc886e14
tree1bab14e9c9b31791da7c742d6fbc166616c03147
parent5e00ad3ffbfb4df7242c313a0d836f5b538eb2fb
analyzer: precision-of-wording for -Wanalyzer-stale-setjmp-buffer

This patch adds a custom event to paths emitted by
-Wanalyzer-stale-setjmp-buffer highlighting the place where the
pertinent stack frame is popped, and updates the final event in
the path to reference this.

gcc/analyzer/ChangeLog:
* checker-path.h (checker_event::get_id_ptr): New.
* diagnostic-manager.cc (path_builder::path_builder): Add "sd"
param and use it to initialize new field "m_sd".
(path_builder::get_pending_diagnostic): New.
(path_builder::m_sd): New field.
(diagnostic_manager::emit_saved_diagnostic): Pass sd to
path_builder ctor.
(diagnostic_manager::add_events_for_superedge): Call new
maybe_add_custom_events_for_superedge vfunc.
* engine.cc (stale_jmp_buf::stale_jmp_buf): Add "setjmp_point"
param and use it to initialize new field "m_setjmp_point".
Initialize new field "m_stack_pop_event".
(stale_jmp_buf::maybe_add_custom_events_for_superedge): New vfunc
implementation.
(stale_jmp_buf::describe_final_event): New vfunc implementation.
(stale_jmp_buf::m_setjmp_point): New field.
(stale_jmp_buf::m_stack_pop_event): New field.
(exploded_node::on_longjmp): Pass setjmp_point to stale_jmp_buf
ctor.
* pending-diagnostic.h
(pending_diagnostic::maybe_add_custom_events_for_superedge): New
vfunc.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/setjmp-5.c: Update expected path output to show
an event where the pertinent stack frame is popped.  Update
expected message from final event to reference this event.
gcc/analyzer/checker-path.h
gcc/analyzer/diagnostic-manager.cc
gcc/analyzer/engine.cc
gcc/analyzer/pending-diagnostic.h
gcc/testsuite/gcc.dg/analyzer/setjmp-5.c