public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1646] analyzer: refactor custom_event, introducing precanned_custom_event class Date: Fri, 18 Jun 2021 15:19:05 +0000 (GMT) [thread overview] Message-ID: <20210618151905.5DAEA3AA9C7B@sourceware.org> (raw) https://gcc.gnu.org/g:86606d2ab731a4b8dbbe1e5318a1920210abd65d commit r12-1646-g86606d2ab731a4b8dbbe1e5318a1920210abd65d Author: David Malcolm <dmalcolm@redhat.com> Date: Fri Jun 18 11:18:10 2021 -0400 analyzer: refactor custom_event, introducing precanned_custom_event class I have followup work where a custom event's description would be better handled via a vfunc rather that a precanned string, hence this refactoring to make it easy to add custom_event subclasses. gcc/analyzer/ChangeLog: * checker-path.cc (class custom_event): Make abstract to allow for custom vfuncs, splitting existing implementation into... (class precanned_custom_event): New subclass. (custom_event::get_desc): Move to... (precanned_custom_event::get_desc): ...subclass. * checker-path.h (class custom_event): Make abstract to allow for custom vfuncs, splitting existing implementation into... (class precanned_custom_event): New subclass. * diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge): Use precanned_custom_event. * engine.cc (stale_jmp_buf::maybe_add_custom_events_for_superedge): Likewise. * sm-signal.cc (signal_delivery_edge_info_t::add_events_to_path): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com> Diff: --- gcc/analyzer/checker-path.cc | 6 +++--- gcc/analyzer/checker-path.h | 22 +++++++++++++++++----- gcc/analyzer/diagnostic-manager.cc | 2 +- gcc/analyzer/engine.cc | 2 +- gcc/analyzer/sm-signal.cc | 7 ++++--- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index e6f838b7d52..e10c8e2bb7c 100644 --- a/gcc/analyzer/checker-path.cc +++ b/gcc/analyzer/checker-path.cc @@ -162,14 +162,14 @@ debug_event::get_desc (bool) const return label_text::borrow (m_desc); } -/* class custom_event : public checker_event. */ +/* class precanned_custom_event : public custom_event. */ /* Implementation of diagnostic_event::get_desc vfunc for - custom_event. + precanned_custom_event. Use the saved string as the event's description. */ label_text -custom_event::get_desc (bool) const +precanned_custom_event::get_desc (bool) const { return label_text::borrow (m_desc); } diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h index f76bb94e7cc..1843c4bc7b4 100644 --- a/gcc/analyzer/checker-path.h +++ b/gcc/analyzer/checker-path.h @@ -56,6 +56,7 @@ extern const char *event_kind_to_string (enum event_kind ek); checker_event debug_event (EK_DEBUG) custom_event (EK_CUSTOM) + precanned_custom_event statement_event (EK_STMT) function_entry_event (EK_FUNCTION_ENTRY) state_change_event (EK_STATE_CHANGE) @@ -144,19 +145,30 @@ private: char *m_desc; }; -/* A concrete event subclass for custom events. These are not filtered, +/* An abstract event subclass for custom events. These are not filtered, as they are likely to be pertinent to the diagnostic. */ class custom_event : public checker_event { +protected: + custom_event (location_t loc, tree fndecl, int depth) + : checker_event (EK_CUSTOM, loc, fndecl, depth) + { + } +}; + +/* A concrete custom_event subclass with a precanned message. */ + +class precanned_custom_event : public custom_event +{ public: - custom_event (location_t loc, tree fndecl, int depth, - const char *desc) - : checker_event (EK_CUSTOM, loc, fndecl, depth), + precanned_custom_event (location_t loc, tree fndecl, int depth, + const char *desc) + : custom_event (loc, fndecl, depth), m_desc (xstrdup (desc)) { } - ~custom_event () + ~precanned_custom_event () { free (m_desc); } diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index 443ff058f65..7eb4ed8a4f2 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -1587,7 +1587,7 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb, "this path would have been rejected as infeasible" " at this edge: "); pb.get_feasibility_problem ()->dump_to_pp (&pp); - emission_path->add_event (new custom_event + emission_path->add_event (new precanned_custom_event (dst_point.get_location (), dst_point.get_fndecl (), dst_stack_depth, diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 529965af187..f322fdb6497 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -1395,7 +1395,7 @@ public: { /* Compare with diagnostic_manager::add_events_for_superedge. */ const int src_stack_depth = src_point.get_stack_depth (); - m_stack_pop_event = new custom_event + m_stack_pop_event = new precanned_custom_event (src_point.get_location (), src_point.get_fndecl (), src_stack_depth, diff --git a/gcc/analyzer/sm-signal.cc b/gcc/analyzer/sm-signal.cc index d7e7e7cab04..42be8094997 100644 --- a/gcc/analyzer/sm-signal.cc +++ b/gcc/analyzer/sm-signal.cc @@ -238,9 +238,10 @@ public: FINAL OVERRIDE { emission_path->add_event - (new custom_event (UNKNOWN_LOCATION, NULL_TREE, 0, - "later on," - " when the signal is delivered to the process")); + (new precanned_custom_event + (UNKNOWN_LOCATION, NULL_TREE, 0, + "later on," + " when the signal is delivered to the process")); } };
reply other threads:[~2021-06-18 15:19 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210618151905.5DAEA3AA9C7B@sourceware.org \ --to=dmalcolm@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).