[6/7,analyzer] Expose state_change_event in evdesc::state_change

Message ID 20191204162530.9285-7-dmalcolm@redhat.com
State New
Headers show
Series
  • Add checking for unsafe calls within signal handlers
Related show

Commit Message

David Malcolm Dec. 4, 2019, 4:25 p.m.
gcc/ChangeLog:
	* analyzer/analyzer.h (class state_change_event): Forward decl.
	* analyzer/checker-path.cc (state_change_event::get_desc): Pass *this
	to evdesc::state_change ctor.
	* analyzer/pending-diagnostic.h
	(evdesc::state_change::state_change): Add a
	const state_change_event & param and use it initialize...
	(evdesc::state_change::m_event): ...this new field.
---
 gcc/analyzer/analyzer.h           | 1 +
 gcc/analyzer/checker-path.cc      | 2 +-
 gcc/analyzer/pending-diagnostic.h | 6 ++++--
 3 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.21.0

Patch

diff --git a/gcc/analyzer/analyzer.h b/gcc/analyzer/analyzer.h
index 19bc2c6d8252..353285c35c36 100644
--- a/gcc/analyzer/analyzer.h
+++ b/gcc/analyzer/analyzer.h
@@ -50,6 +50,7 @@  struct model_merger;
 struct svalue_id_merger_mapping;
 struct canonicalization;
 class pending_diagnostic;
+class state_change_event;
 class checker_path;
 class extrinsic_state;
 class sm_state_map;
diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc
index bc47380bc3f5..554a20f31bec 100644
--- a/gcc/analyzer/checker-path.cc
+++ b/gcc/analyzer/checker-path.cc
@@ -229,7 +229,7 @@  state_change_event::get_desc (bool can_colorize) const
       label_text custom_desc
 	= m_pending_diagnostic->describe_state_change
 	    (evdesc::state_change (can_colorize, m_var, m_origin,
-				   m_from, m_to, m_emission_id));
+				   m_from, m_to, m_emission_id, *this));
       if (custom_desc.m_buffer)
 	{
 	  if (flag_analyzer_verbose_state_changes)
diff --git a/gcc/analyzer/pending-diagnostic.h b/gcc/analyzer/pending-diagnostic.h
index 4103a91e2f56..15a1379e8fd1 100644
--- a/gcc/analyzer/pending-diagnostic.h
+++ b/gcc/analyzer/pending-diagnostic.h
@@ -50,11 +50,12 @@  struct state_change : public event_desc
 		tree origin,
 		state_machine::state_t old_state,
 		state_machine::state_t new_state,
-		diagnostic_event_id_t event_id)
+		diagnostic_event_id_t event_id,
+		const state_change_event &event)
   : event_desc (colorize),
     m_expr (expr), m_origin (origin),
     m_old_state (old_state), m_new_state (new_state),
-    m_event_id (event_id)
+    m_event_id (event_id), m_event (event)
   {}
 
   bool is_global_p () const { return m_expr == NULL_TREE; }
@@ -64,6 +65,7 @@  struct state_change : public event_desc
   state_machine::state_t m_old_state;
   state_machine::state_t m_new_state;
   diagnostic_event_id_t m_event_id;
+  const state_change_event &m_event;
 };
 
 /* For use by pending_diagnostic::describe_call_with_state.  */