This patch adds a custom_event subclass for diagnostics that need non-standard events (e.g. signal handlers).
gcc/ChangeLog: * analyzer/checker-path.cc (event_kind_to_string): Handle EK_CUSTOM. (custom_event::get_desc): New vfunc implementation. * analyzer/checker-path (class custom_event): New. * analyzer/diagnostic-manager.cc (diagnostic_manager::prune_path): Handle EK_CUSTOM. --- gcc/analyzer/checker-path.cc | 16 ++++++++++++++++ gcc/analyzer/checker-path.h | 30 ++++++++++++++++++++++++++++++ gcc/analyzer/diagnostic-manager.cc | 4 ++++ 3 files changed, 50 insertions(+) diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index c0783df9e8e9..bc47380bc3f5 100644 --- a/gcc/analyzer/checker-path.cc +++ b/gcc/analyzer/checker-path.cc @@ -44,6 +44,8 @@ event_kind_to_string (enum event_kind ek) gcc_unreachable (); case EK_DEBUG: return "EK_DEBUG"; + case EK_CUSTOM: + return "EK_CUSTOM"; case EK_STMT: return "EK_STMT"; case EK_FUNCTION_ENTRY: @@ -129,6 +131,20 @@ debug_event::get_desc (bool) const //////////////////////////////////////////////////////////////////////////// +/* class custom_event : public checker_event. */ + +/* Implementation of diagnostic_event::get_desc vfunc for + custom_event. + Use the saved string as the event's description. */ + +label_text +custom_event::get_desc (bool) const +{ + return label_text::borrow (m_desc); +} + +//////////////////////////////////////////////////////////////////////////// + /* class statement_event : public checker_event. */ /* statement_event's ctor. */ diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h index ccff8f2ea0bc..f5f27e7e3bba 100644 --- a/gcc/analyzer/checker-path.h +++ b/gcc/analyzer/checker-path.h @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see enum event_kind { EK_DEBUG, + EK_CUSTOM, EK_STMT, EK_FUNCTION_ENTRY, EK_STATE_CHANGE, @@ -57,6 +58,7 @@ extern const char *event_kind_to_string (enum event_kind ek); diagnostic_event checker_event debug_event (EK_DEBUG) + custom_event (EK_CUSTOM) statement_event (EK_STMT) function_entry_event (EK_FUNCTION_ENTRY) state_change_event (EK_STATE_CHANGE) @@ -142,6 +144,34 @@ private: char *m_desc; }; +/* A concrete 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 +{ +public: + custom_event (location_t loc, tree fndecl, int depth, + const char *desc) + : checker_event (EK_CUSTOM, loc, fndecl, depth), + m_desc (xstrdup (desc)) + { + } + ~custom_event () + { + free (m_desc); + } + + label_text get_desc (bool) const FINAL OVERRIDE; + + checker_event *clone () const FINAL OVERRIDE + { + return new custom_event (m_loc, m_fndecl, m_depth, m_desc); + } + +private: + char *m_desc; +}; + /* A concrete event subclass describing the execution of a gimple statement, for use at high verbosity levels when debugging paths. */ diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index 694993cab10b..cbbba4e8de40 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -919,6 +919,10 @@ diagnostic_manager::prune_path (checker_path *path, } break; + case EK_CUSTOM: + /* Don't filter custom events. */ + break; + case EK_STMT: { /* If this stmt is the origin of "var", update var. */ -- 2.21.0