From 5743e1899d596497800f7d6f4273d535ea0abcdd Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 4 Jan 2024 09:15:18 -0500 Subject: analyzer: fix deref-before-check false positives due to inlining [PR112790] gcc/analyzer/ChangeLog: PR analyzer/112790 * checker-event.cc (class inlining_info): Move to... * inlining-iterator.h (class inlining_info): ...here. * sm-malloc.cc: Include "analyzer/inlining-iterator.h". (maybe_complain_about_deref_before_check): Reject stmts that were inlined from another function. gcc/testsuite/ChangeLog: PR analyzer/112790 * c-c++-common/analyzer/deref-before-check-pr112790.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/checker-event.cc | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'gcc/analyzer/checker-event.cc') diff --git a/gcc/analyzer/checker-event.cc b/gcc/analyzer/checker-event.cc index c9c07b3c..2000db9 100644 --- a/gcc/analyzer/checker-event.cc +++ b/gcc/analyzer/checker-event.cc @@ -106,46 +106,6 @@ event_kind_to_string (enum event_kind ek) } } -/* A class for fixing up fndecls and stack depths in checker_event, based - on inlining records. - - The early inliner runs before the analyzer, which can lead to confusing - output. - - Tne base fndecl and depth within a checker_event are from call strings - in program_points, which reflect the call strings after inlining. - This class lets us offset the depth and fix up the reported fndecl and - stack depth to better reflect the user's original code. */ - -class inlining_info -{ -public: - inlining_info (location_t loc) - { - inlining_iterator iter (loc); - m_inner_fndecl = iter.get_fndecl (); - int num_frames = 0; - while (!iter.done_p ()) - { - m_outer_fndecl = iter.get_fndecl (); - num_frames++; - iter.next (); - } - if (num_frames > 1) - m_extra_frames = num_frames - 1; - else - m_extra_frames = 0; - } - - tree get_inner_fndecl () const { return m_inner_fndecl; } - int get_extra_frames () const { return m_extra_frames; } - -private: - tree m_outer_fndecl; - tree m_inner_fndecl; - int m_extra_frames; -}; - /* class checker_event : public diagnostic_event. */ /* checker_event's ctor. */ -- cgit v1.1