public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4472] analyzer: introduce struct event_loc_info
@ 2022-12-02 21:32 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-12-02 21:32 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e24fe1283ca1c4d22dc3cf29c26d7b705fb0a568

commit r13-4472-ge24fe1283ca1c4d22dc3cf29c26d7b705fb0a568
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Fri Dec 2 16:30:52 2022 -0500

    analyzer: introduce struct event_loc_info
    
    gcc/analyzer/ChangeLog:
            * analyzer.h (struct event_loc_info): New forward decl.
            * bounds-checking.cc: Use event_loc_info throughout to bundle the
            loc, fndecl, depth triples.
            * call-info.cc: Likewise.
            * checker-event.cc: Likewise.
            * checker-event.h (struct event_loc_info): New decl.  Use it
            throughout to bundle the loc, fndecl, depth triples.
            * checker-path.cc: Likewise.
            * checker-path.h: Likewise.
            * diagnostic-manager.cc: Likewise.
            * engine.cc: Likewise.
            * infinite-recursion.cc: Likewise.
            * pending-diagnostic.cc: Likewise.
            * pending-diagnostic.h: Likewise.
            * region-model.cc: Likewise.
            * sm-signal.cc: Likewise.
            * varargs.cc: Likewise.
    
    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

Diff:
---
 gcc/analyzer/analyzer.h            |   1 +
 gcc/analyzer/bounds-checking.cc    |  12 ++---
 gcc/analyzer/call-info.cc          |  15 +++---
 gcc/analyzer/checker-event.cc      |  55 ++++++++++----------
 gcc/analyzer/checker-event.h       | 104 +++++++++++++++++++++----------------
 gcc/analyzer/checker-path.cc       |   7 ++-
 gcc/analyzer/checker-path.h        |   3 +-
 gcc/analyzer/diagnostic-manager.cc |  85 +++++++++++++++---------------
 gcc/analyzer/engine.cc             |  63 +++++++++++-----------
 gcc/analyzer/infinite-recursion.cc |   7 +--
 gcc/analyzer/pending-diagnostic.cc |  28 +++++-----
 gcc/analyzer/pending-diagnostic.h  |   3 +-
 gcc/analyzer/region-model.cc       |   6 +--
 gcc/analyzer/sm-signal.cc          |   2 +-
 gcc/analyzer/varargs.cc            |  17 +++---
 15 files changed, 211 insertions(+), 197 deletions(-)

diff --git a/gcc/analyzer/analyzer.h b/gcc/analyzer/analyzer.h
index e0fdbad61a7..a2d363f1249 100644
--- a/gcc/analyzer/analyzer.h
+++ b/gcc/analyzer/analyzer.h
@@ -92,6 +92,7 @@ class bounded_ranges_manager;
 
 class pending_diagnostic;
 class pending_note;
+struct event_loc_info;
 class state_change_event;
 class checker_path;
 class extrinsic_state;
diff --git a/gcc/analyzer/bounds-checking.cc b/gcc/analyzer/bounds-checking.cc
index 17f183fea21..4b43c43acf5 100644
--- a/gcc/analyzer/bounds-checking.cc
+++ b/gcc/analyzer/bounds-checking.cc
@@ -68,16 +68,14 @@ public:
 
   void add_region_creation_events (const region *,
 				   tree capacity,
-				   location_t loc,
-				   tree fndecl, int depth,
+				   const event_loc_info &loc_info,
 				   checker_path &emission_path) override
   {
     /* The memory space is described in the diagnostic message itself,
        so we don't need an event for that.  */
     if (capacity)
       emission_path.add_event
-	(make_unique<region_creation_event_capacity> (capacity,
-						      loc, fndecl, depth));
+	(make_unique<region_creation_event_capacity> (capacity, loc_info));
   }
 
 protected:
@@ -165,14 +163,12 @@ public:
 
   void add_region_creation_events (const region *,
 				   tree,
-				   location_t loc,
-				   tree fndecl, int depth,
+				   const event_loc_info &loc_info,
 				   checker_path &emission_path) final override
   {
     if (m_byte_bound && TREE_CODE (m_byte_bound) == INTEGER_CST)
       emission_path.add_event
-	(make_unique<region_creation_event_capacity> (m_byte_bound,
-						      loc, fndecl, depth));
+	(make_unique<region_creation_event_capacity> (m_byte_bound, loc_info));
   }
 
 protected:
diff --git a/gcc/analyzer/call-info.cc b/gcc/analyzer/call-info.cc
index 7a1c4edfcae..44a66be075a 100644
--- a/gcc/analyzer/call-info.cc
+++ b/gcc/analyzer/call-info.cc
@@ -94,10 +94,10 @@ call_info::add_events_to_path (checker_path *emission_path,
   class call_event : public custom_event
   {
   public:
-    call_event (location_t loc, tree fndecl, int depth,
+    call_event (const event_loc_info &loc_info,
 		const call_info *call_info)
-      : custom_event (loc, fndecl, depth),
-	m_call_info (call_info)
+    : custom_event (loc_info),
+      m_call_info (call_info)
     {}
 
     label_text get_desc (bool can_colorize) const final override
@@ -114,10 +114,11 @@ call_info::add_events_to_path (checker_path *emission_path,
   tree caller_fndecl = src_point.get_fndecl ();
   const int stack_depth = src_point.get_stack_depth ();
 
-  emission_path->add_event (make_unique<call_event> (get_call_stmt ()->location,
-						     caller_fndecl,
-						     stack_depth,
-						     this));
+  emission_path->add_event
+    (make_unique<call_event> (event_loc_info (get_call_stmt ()->location,
+					      caller_fndecl,
+					      stack_depth),
+			      this));
 }
 
 /* Recreate a call_details instance from this call_info.  */
diff --git a/gcc/analyzer/checker-event.cc b/gcc/analyzer/checker-event.cc
index 98f1053da8f..4985f632f20 100644
--- a/gcc/analyzer/checker-event.cc
+++ b/gcc/analyzer/checker-event.cc
@@ -151,17 +151,19 @@ private:
 /* checker_event's ctor.  */
 
 checker_event::checker_event (enum event_kind kind,
-			      location_t loc, tree fndecl, int depth)
-: m_kind (kind), m_loc (loc),
-  m_original_fndecl (fndecl), m_effective_fndecl (fndecl),
-  m_original_depth (depth), m_effective_depth (depth),
+			      const event_loc_info &loc_info)
+: m_kind (kind), m_loc (loc_info.m_loc),
+  m_original_fndecl (loc_info.m_fndecl),
+  m_effective_fndecl (loc_info.m_fndecl),
+  m_original_depth (loc_info.m_depth),
+  m_effective_depth (loc_info.m_depth),
   m_pending_diagnostic (NULL), m_emission_id (),
-  m_logical_loc (fndecl)
+  m_logical_loc (loc_info.m_fndecl)
 {
   /* Update effective fndecl and depth if inlining has been recorded.  */
   if (flag_analyzer_undo_inlining)
     {
-      inlining_info info (loc);
+      inlining_info info (m_loc);
       if (info.get_inner_fndecl ())
 	{
 	  m_effective_fndecl = info.get_inner_fndecl ();
@@ -272,7 +274,8 @@ precanned_custom_event::get_desc (bool) const
 
 statement_event::statement_event (const gimple *stmt, tree fndecl, int depth,
 				  const program_state &dst_state)
-: checker_event (EK_STMT, gimple_location (stmt), fndecl, depth),
+: checker_event (EK_STMT,
+		 event_loc_info (gimple_location (stmt), fndecl, depth)),
   m_stmt (stmt),
   m_dst_state (dst_state)
 {
@@ -293,10 +296,8 @@ statement_event::get_desc (bool) const
 
 /* class region_creation_event : public checker_event.  */
 
-region_creation_event::region_creation_event (location_t loc,
-					      tree fndecl,
-					      int depth)
-: checker_event (EK_REGION_CREATION, loc, fndecl, depth)
+region_creation_event::region_creation_event (const event_loc_info &loc_info)
+: checker_event (EK_REGION_CREATION, loc_info)
 {
 }
 
@@ -370,9 +371,10 @@ region_creation_event_debug::get_desc (bool) const
 
 function_entry_event::function_entry_event (const program_point &dst_point)
 : checker_event (EK_FUNCTION_ENTRY,
-		 dst_point.get_supernode ()->get_start_location (),
-		 dst_point.get_fndecl (),
-		 dst_point.get_stack_depth ())
+		 event_loc_info (dst_point.get_supernode
+				   ()->get_start_location (),
+				 dst_point.get_fndecl (),
+				 dst_point.get_stack_depth ()))
 {
 }
 
@@ -410,8 +412,9 @@ state_change_event::state_change_event (const supernode *node,
 					const svalue *origin,
 					const program_state &dst_state)
 : checker_event (EK_STATE_CHANGE,
-		 stmt->location, node->m_fun->decl,
-		 stack_depth),
+		 event_loc_info (stmt->location,
+				 node->m_fun->decl,
+				 stack_depth)),
   m_node (node), m_stmt (stmt), m_sm (sm),
   m_sval (sval), m_from (from), m_to (to),
   m_origin (origin),
@@ -578,8 +581,8 @@ superedge_event::should_filter_p (int verbosity) const
 
 superedge_event::superedge_event (enum event_kind kind,
 				  const exploded_edge &eedge,
-				  location_t loc, tree fndecl, int depth)
-: checker_event (kind, loc, fndecl, depth),
+				  const event_loc_info &loc_info)
+: checker_event (kind, loc_info),
   m_eedge (eedge), m_sedge (eedge.m_sedge),
   m_var (NULL_TREE), m_critical_state (0)
 {
@@ -599,8 +602,8 @@ cfg_edge_event::get_cfg_superedge () const
 
 cfg_edge_event::cfg_edge_event (enum event_kind kind,
 				const exploded_edge &eedge,
-				location_t loc, tree fndecl, int depth)
-: superedge_event (kind, eedge, loc, fndecl, depth)
+				const event_loc_info &loc_info)
+: superedge_event (kind, eedge, loc_info)
 {
   gcc_assert (eedge.m_sedge->m_kind == SUPEREDGE_CFG_EDGE);
 }
@@ -815,8 +818,8 @@ start_cfg_edge_event::should_print_expr_p (tree expr)
 /* call_event's ctor.  */
 
 call_event::call_event (const exploded_edge &eedge,
-			location_t loc, tree fndecl, int depth)
-: superedge_event (EK_CALL_EDGE, eedge, loc, fndecl, depth)
+			const event_loc_info &loc_info)
+: superedge_event (EK_CALL_EDGE, eedge, loc_info)
 {
   if (eedge.m_sedge)
     gcc_assert (eedge.m_sedge->m_kind == SUPEREDGE_CALL);
@@ -894,8 +897,8 @@ call_event::get_callee_fndecl () const
 /* return_event's ctor.  */
 
 return_event::return_event (const exploded_edge &eedge,
-			    location_t loc, tree fndecl, int depth)
-: superedge_event (EK_RETURN_EDGE, eedge, loc, fndecl, depth)
+			    const event_loc_info &loc_info)
+: superedge_event (EK_RETURN_EDGE, eedge, loc_info)
 {
   if (eedge.m_sedge)
     gcc_assert (eedge.m_sedge->m_kind == SUPEREDGE_RETURN);
@@ -1045,9 +1048,9 @@ rewind_event::get_setjmp_caller () const
 
 rewind_event::rewind_event (const exploded_edge *eedge,
 			    enum event_kind kind,
-			    location_t loc, tree fndecl, int depth,
+			    const event_loc_info &loc_info,
 			    const rewind_info_t *rewind_info)
-: checker_event (kind, loc, fndecl, depth),
+: checker_event (kind, loc_info),
   m_rewind_info (rewind_info),
   m_eedge (eedge)
 {
diff --git a/gcc/analyzer/checker-event.h b/gcc/analyzer/checker-event.h
index f9885f5cfc3..6dac647b872 100644
--- a/gcc/analyzer/checker-event.h
+++ b/gcc/analyzer/checker-event.h
@@ -26,6 +26,19 @@ along with GCC; see the file COPYING3.  If not see
 
 namespace ana {
 
+/* A bundle of location information for a checker_event.  */
+
+struct event_loc_info
+{
+  event_loc_info (location_t loc, tree fndecl, int depth)
+  : m_loc (loc), m_fndecl (fndecl), m_depth (depth)
+  {}
+
+  location_t m_loc;
+  tree m_fndecl;
+  int m_depth;
+};
+
 /* An enum for discriminating between the concrete subclasses of
    checker_event.  */
 
@@ -125,7 +138,7 @@ public:
 
 protected:
   checker_event (enum event_kind kind,
-		 location_t loc, tree fndecl, int depth);
+		 const event_loc_info &loc_info);
 
  public:
   const enum event_kind m_kind;
@@ -146,9 +159,10 @@ protected:
 class debug_event : public checker_event
 {
 public:
-  debug_event (location_t loc, tree fndecl, int depth,
-	      const char *desc)
-  : checker_event (EK_DEBUG, loc, fndecl, depth),
+
+  debug_event (const event_loc_info &loc_info,
+	       const char *desc)
+  : checker_event (EK_DEBUG, loc_info),
     m_desc (xstrdup (desc))
   {
   }
@@ -169,8 +183,8 @@ private:
 class custom_event : public checker_event
 {
 protected:
-  custom_event (location_t loc, tree fndecl, int depth)
-  : checker_event (EK_CUSTOM, loc, fndecl, depth)
+  custom_event (const event_loc_info &loc_info)
+  : checker_event (EK_CUSTOM, loc_info)
   {
   }
 };
@@ -180,9 +194,9 @@ protected:
 class precanned_custom_event : public custom_event
 {
 public:
-  precanned_custom_event (location_t loc, tree fndecl, int depth,
+  precanned_custom_event (const event_loc_info &loc_info,
 			  const char *desc)
-  : custom_event (loc, fndecl, depth),
+  : custom_event (loc_info),
     m_desc (xstrdup (desc))
   {
   }
@@ -230,7 +244,7 @@ public:
 class region_creation_event : public checker_event
 {
 protected:
-  region_creation_event (location_t loc, tree fndecl, int depth);
+  region_creation_event (const event_loc_info &loc_info);
 };
 
 /* Concrete subclass of region_creation_event.
@@ -241,8 +255,8 @@ class region_creation_event_memory_space : public region_creation_event
 {
 public:
   region_creation_event_memory_space (enum memory_space mem_space,
-				      location_t loc, tree fndecl, int depth)
-  : region_creation_event (loc, fndecl, depth),
+				      const event_loc_info &loc_info)
+  : region_creation_event (loc_info),
     m_mem_space (mem_space)
   {
   }
@@ -261,8 +275,8 @@ class region_creation_event_capacity : public region_creation_event
 {
 public:
   region_creation_event_capacity (tree capacity,
-				  location_t loc, tree fndecl, int depth)
-  : region_creation_event (loc, fndecl, depth),
+				  const event_loc_info &loc_info)
+  : region_creation_event (loc_info),
     m_capacity (capacity)
   {
     gcc_assert (m_capacity);
@@ -282,8 +296,8 @@ class region_creation_event_allocation_size : public region_creation_event
 {
 public:
   region_creation_event_allocation_size (tree capacity,
-					 location_t loc, tree fndecl, int depth)
-  : region_creation_event (loc, fndecl, depth),
+					 const event_loc_info &loc_info)
+  : region_creation_event (loc_info),
     m_capacity (capacity)
   {}
 
@@ -300,8 +314,8 @@ class region_creation_event_debug : public region_creation_event
 {
 public:
   region_creation_event_debug (const region *reg, tree capacity,
-			       location_t loc, tree fndecl, int depth)
-  : region_creation_event (loc, fndecl, depth),
+			       const event_loc_info &loc_info)
+  : region_creation_event (loc_info),
     m_reg (reg), m_capacity (capacity)
   {
   }
@@ -318,8 +332,8 @@ private:
 class function_entry_event : public checker_event
 {
 public:
-  function_entry_event (location_t loc, tree fndecl, int depth)
-  : checker_event (EK_FUNCTION_ENTRY, loc, fndecl, depth)
+  function_entry_event (const event_loc_info &loc_info)
+  : checker_event (EK_FUNCTION_ENTRY, loc_info)
   {
   }
 
@@ -385,7 +399,7 @@ public:
 
  protected:
   superedge_event (enum event_kind kind, const exploded_edge &eedge,
-		   location_t loc, tree fndecl, int depth);
+		   const event_loc_info &loc_info);
 
  public:
   const exploded_edge &m_eedge;
@@ -407,7 +421,7 @@ public:
 
  protected:
   cfg_edge_event (enum event_kind kind, const exploded_edge &eedge,
-		  location_t loc, tree fndecl, int depth);
+		  const event_loc_info &loc_info);
 };
 
 /* A concrete event subclass for the start of a CFG edge
@@ -417,8 +431,8 @@ class start_cfg_edge_event : public cfg_edge_event
 {
 public:
   start_cfg_edge_event (const exploded_edge &eedge,
-			location_t loc, tree fndecl, int depth)
-  : cfg_edge_event (EK_START_CFG_EDGE, eedge, loc, fndecl, depth)
+			const event_loc_info &loc_info)
+  : cfg_edge_event (EK_START_CFG_EDGE, eedge, loc_info)
   {
   }
 
@@ -441,8 +455,8 @@ class end_cfg_edge_event : public cfg_edge_event
 {
 public:
   end_cfg_edge_event (const exploded_edge &eedge,
-		      location_t loc, tree fndecl, int depth)
-  : cfg_edge_event (EK_END_CFG_EDGE, eedge, loc, fndecl, depth)
+		      const event_loc_info &loc_info)
+  : cfg_edge_event (EK_END_CFG_EDGE, eedge, loc_info)
   {
   }
 
@@ -458,7 +472,7 @@ class call_event : public superedge_event
 {
 public:
   call_event (const exploded_edge &eedge,
-	      location_t loc, tree fndecl, int depth);
+	      const event_loc_info &loc_info);
 
   label_text get_desc (bool can_colorize) const override;
   meaning get_meaning () const override;
@@ -479,7 +493,7 @@ class return_event : public superedge_event
 {
 public:
   return_event (const exploded_edge &eedge,
-		location_t loc, tree fndecl, int depth);
+		const event_loc_info &loc_info);
 
   label_text get_desc (bool can_colorize) const final override;
   meaning get_meaning () const override;
@@ -496,9 +510,9 @@ public:
 class start_consolidated_cfg_edges_event : public checker_event
 {
 public:
-  start_consolidated_cfg_edges_event (location_t loc, tree fndecl, int depth,
+  start_consolidated_cfg_edges_event (const event_loc_info &loc_info,
 				      bool edge_sense)
-  : checker_event (EK_START_CONSOLIDATED_CFG_EDGES, loc, fndecl, depth),
+  : checker_event (EK_START_CONSOLIDATED_CFG_EDGES, loc_info),
     m_edge_sense (edge_sense)
   {
   }
@@ -516,8 +530,8 @@ public:
 class end_consolidated_cfg_edges_event : public checker_event
 {
 public:
-  end_consolidated_cfg_edges_event (location_t loc, tree fndecl, int depth)
-  : checker_event (EK_END_CONSOLIDATED_CFG_EDGES, loc, fndecl, depth)
+  end_consolidated_cfg_edges_event (const event_loc_info &loc_info)
+  : checker_event (EK_END_CONSOLIDATED_CFG_EDGES, loc_info)
   {
   }
 
@@ -538,9 +552,10 @@ public:
 		      tree apparent_caller_fndecl,
 		      int actual_depth,
 		      int stack_depth_adjustment)
-  : checker_event (EK_INLINED_CALL, loc,
-		   apparent_caller_fndecl,
-		   actual_depth + stack_depth_adjustment),
+  : checker_event (EK_INLINED_CALL,
+		   event_loc_info (loc,
+				   apparent_caller_fndecl,
+				   actual_depth + stack_depth_adjustment)),
     m_apparent_callee_fndecl (apparent_callee_fndecl),
     m_apparent_caller_fndecl (apparent_caller_fndecl)
   {
@@ -560,9 +575,10 @@ private:
 class setjmp_event : public checker_event
 {
 public:
-  setjmp_event (location_t loc, const exploded_node *enode,
-		tree fndecl, int depth, const gcall *setjmp_call)
-  : checker_event (EK_SETJMP, loc, fndecl, depth),
+  setjmp_event (const event_loc_info &loc_info,
+		const exploded_node *enode,
+		const gcall *setjmp_call)
+  : checker_event (EK_SETJMP, loc_info),
     m_enode (enode), m_setjmp_call (setjmp_call)
   {
   }
@@ -594,7 +610,7 @@ public:
  protected:
   rewind_event (const exploded_edge *eedge,
 		enum event_kind kind,
-		location_t loc, tree fndecl, int depth,
+		const event_loc_info &loc_info,
 		const rewind_info_t *rewind_info);
   const rewind_info_t *m_rewind_info;
 
@@ -609,9 +625,9 @@ class rewind_from_longjmp_event : public rewind_event
 {
 public:
   rewind_from_longjmp_event (const exploded_edge *eedge,
-			     location_t loc, tree fndecl, int depth,
+			     const event_loc_info &loc_info,
 			     const rewind_info_t *rewind_info)
-  : rewind_event (eedge, EK_REWIND_FROM_LONGJMP, loc, fndecl, depth,
+  : rewind_event (eedge, EK_REWIND_FROM_LONGJMP, loc_info,
 		  rewind_info)
   {
   }
@@ -626,9 +642,9 @@ class rewind_to_setjmp_event : public rewind_event
 {
 public:
   rewind_to_setjmp_event (const exploded_edge *eedge,
-			  location_t loc, tree fndecl, int depth,
+			  const event_loc_info &loc_info,
 			  const rewind_info_t *rewind_info)
-  : rewind_event (eedge, EK_REWIND_TO_SETJMP, loc, fndecl, depth,
+  : rewind_event (eedge, EK_REWIND_TO_SETJMP, loc_info,
 		  rewind_info)
   {
   }
@@ -651,10 +667,10 @@ private:
 class warning_event : public checker_event
 {
 public:
-  warning_event (location_t loc, tree fndecl, int depth,
+  warning_event (const event_loc_info &loc_info,
 		 const state_machine *sm,
 		 tree var, state_machine::state_t state)
-  : checker_event (EK_WARNING, loc, fndecl, depth),
+  : checker_event (EK_WARNING, loc_info),
     m_sm (sm), m_var (var), m_state (state)
   {
   }
diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc
index 0cc0b2bf81f..c229e4675e0 100644
--- a/gcc/analyzer/checker-path.cc
+++ b/gcc/analyzer/checker-path.cc
@@ -144,8 +144,7 @@ void
 checker_path::add_region_creation_events (pending_diagnostic *pd,
 					  const region *reg,
 					  const region_model *model,
-					  location_t loc,
-					  tree fndecl, int depth,
+					  const event_loc_info &loc_info,
 					  bool debug)
 {
   tree capacity = NULL_TREE;
@@ -153,11 +152,11 @@ checker_path::add_region_creation_events (pending_diagnostic *pd,
     if (const svalue *capacity_sval = model->get_capacity (reg))
       capacity = model->get_representative_tree (capacity_sval);
 
-  pd->add_region_creation_events (reg, capacity, loc, fndecl, depth, *this);
+  pd->add_region_creation_events (reg, capacity, loc_info, *this);
 
   if (debug)
     add_event (make_unique<region_creation_event_debug> (reg, capacity,
-							 loc, fndecl, depth));
+							 loc_info));
 }
 
 void
diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h
index ba04aed069e..de1f6203b03 100644
--- a/gcc/analyzer/checker-path.h
+++ b/gcc/analyzer/checker-path.h
@@ -79,8 +79,7 @@ public:
   void add_region_creation_events (pending_diagnostic *pd,
 				   const region *reg,
 				   const region_model *model,
-				   location_t loc,
-				   tree fndecl, int depth,
+				   const event_loc_info &loc_info,
 				   bool debug);
 
   /* After all event-pruning, a hook for notifying each event what
diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index 0574758be5a..9cc02da4691 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -1449,9 +1449,9 @@ diagnostic_manager::build_emission_path (const path_builder &pb,
 		  emission_path->add_region_creation_events
 		    (pb.get_pending_diagnostic (),
 		     reg, NULL,
-		     DECL_SOURCE_LOCATION (decl),
-		     NULL_TREE,
-		     0,
+		     event_loc_info (DECL_SOURCE_LOCATION (decl),
+				     NULL_TREE,
+				     0),
 		     m_verbosity > 3);
 		}
 	  }
@@ -1518,9 +1518,9 @@ diagnostic_manager::add_event_on_final_node (const path_builder &pb,
 		    (pb.get_pending_diagnostic (),
 		     reg,
 		     dst_model,
-		     src_point.get_location (),
-		     src_point.get_fndecl (),
-		     src_stack_depth,
+		     event_loc_info (src_point.get_location (),
+				     src_point.get_fndecl (),
+				     src_stack_depth),
 		     false);
 		  emitted = true;
 		  break;
@@ -1946,9 +1946,9 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
 			    emission_path->add_region_creation_events
 			      (pb.get_pending_diagnostic (),
 			       reg, dst_state.m_region_model,
-			       DECL_SOURCE_LOCATION (decl),
-			       dst_point.get_fndecl (),
-			       dst_stack_depth,
+			       event_loc_info (DECL_SOURCE_LOCATION (decl),
+					       dst_point.get_fndecl (),
+					       dst_stack_depth),
 			       m_verbosity > 3);
 			  }
 		    }
@@ -1961,10 +1961,10 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
 	const gcall *call = dyn_cast <const gcall *> (stmt);
 	if (call && is_setjmp_call_p (call))
 	  emission_path->add_event
-	    (make_unique<setjmp_event> (stmt->location,
+	    (make_unique<setjmp_event> (event_loc_info (stmt->location,
+							dst_point.get_fndecl (),
+							dst_stack_depth),
 					dst_node,
-					dst_point.get_fndecl (),
-					dst_stack_depth,
 					call));
 	else
 	  emission_path->add_event
@@ -2043,9 +2043,9 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
 		    emission_path->add_region_creation_events
 		      (pb.get_pending_diagnostic (),
 		       reg, dst_model,
-		       src_point.get_location (),
-		       src_point.get_fndecl (),
-		       src_stack_depth,
+		       event_loc_info (src_point.get_location (),
+				       src_point.get_fndecl (),
+				       src_stack_depth),
 		       m_verbosity > 3);
 		    break;
 		  }
@@ -2064,9 +2064,9 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
       pb.get_feasibility_problem ()->dump_to_pp (&pp);
       emission_path->add_event
 	(make_unique<precanned_custom_event>
-	 (dst_point.get_location (),
-	  dst_point.get_fndecl (),
-	  dst_stack_depth,
+	 (event_loc_info (dst_point.get_location (),
+			  dst_point.get_fndecl (),
+			  dst_stack_depth),
 	  pp_formatted_text (&pp)));
     }
 }
@@ -2178,18 +2178,17 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb,
     case SUPEREDGE_CFG_EDGE:
       {
 	emission_path->add_event
-	  (make_unique<start_cfg_edge_event> (eedge,
-					      (last_stmt
-					       ? last_stmt->location
-					       : UNKNOWN_LOCATION),
-					      src_point.get_fndecl (),
-					      src_stack_depth));
+	  (make_unique<start_cfg_edge_event>
+	   (eedge,
+	    event_loc_info (last_stmt ? last_stmt->location : UNKNOWN_LOCATION,
+			    src_point.get_fndecl (),
+			    src_stack_depth)));
 	emission_path->add_event
 	  (make_unique<end_cfg_edge_event>
 	    (eedge,
-	     dst_point.get_supernode ()->get_start_location (),
-	     dst_point.get_fndecl (),
-	     dst_stack_depth));
+	     event_loc_info (dst_point.get_supernode ()->get_start_location (),
+			     dst_point.get_fndecl (),
+			     dst_stack_depth)));
       }
       break;
 
@@ -2202,11 +2201,11 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb,
 	/* TODO: add a subclass for this, or generate events for the
 	   summary.  */
 	emission_path->add_event
-	  (make_unique<debug_event> ((last_stmt
-				      ? last_stmt->location
-				      : UNKNOWN_LOCATION),
-				     src_point.get_fndecl (),
-				     src_stack_depth,
+	  (make_unique<debug_event> (event_loc_info (last_stmt
+						     ? last_stmt->location
+						     : UNKNOWN_LOCATION,
+						     src_point.get_fndecl (),
+						     src_stack_depth),
 				     "call summary"));
       }
       break;
@@ -2219,11 +2218,11 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb,
 	const gcall *call_stmt = return_edge->get_call_stmt ();
 	emission_path->add_event
 	  (make_unique<return_event> (eedge,
-				      (call_stmt
-				       ? call_stmt->location
-				       : UNKNOWN_LOCATION),
-				      dst_point.get_fndecl (),
-				      dst_stack_depth));
+				      event_loc_info (call_stmt
+						      ? call_stmt->location
+						      : UNKNOWN_LOCATION,
+						      dst_point.get_fndecl (),
+						      dst_stack_depth)));
       }
       break;
     }
@@ -2765,15 +2764,15 @@ diagnostic_manager::consolidate_conditions (checker_path *path) const
 		   start_idx, next_idx - 1, start_idx, start_idx +1);
 	      start_consolidated_cfg_edges_event *new_start_ev
 		= new start_consolidated_cfg_edges_event
-		(old_start_ev->get_location (),
-		 old_start_ev->get_fndecl (),
-		 old_start_ev->get_stack_depth (),
+		(event_loc_info (old_start_ev->get_location (),
+				 old_start_ev->get_fndecl (),
+				 old_start_ev->get_stack_depth ()),
 		 edge_sense);
 	      checker_event *new_end_ev
 		= new end_consolidated_cfg_edges_event
-		(old_end_ev->get_location (),
-		 old_end_ev->get_fndecl (),
-		 old_end_ev->get_stack_depth ());
+		(event_loc_info (old_end_ev->get_location (),
+				 old_end_ev->get_fndecl (),
+				 old_end_ev->get_stack_depth ()));
 	      path->replace_event (start_idx, new_start_ev);
 	      path->replace_event (start_idx + 1, new_end_ev);
 	      path->delete_events (start_idx + 2, next_idx - (start_idx + 2));
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 991b592b828..b3b81cca856 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -1789,9 +1789,9 @@ public:
 	/* Compare with diagnostic_manager::add_events_for_superedge.  */
 	const int src_stack_depth = src_point.get_stack_depth ();
 	m_stack_pop_event = new precanned_custom_event
-	  (src_point.get_location (),
-	   src_point.get_fndecl (),
-	   src_stack_depth,
+	  (event_loc_info (src_point.get_location (),
+			   src_point.get_fndecl (),
+			   src_stack_depth),
 	   "stack frame is popped here, invalidating saved environment");
 	emission_path->add_event
 	  (std::unique_ptr<custom_event> (m_stack_pop_event));
@@ -2045,19 +2045,19 @@ dynamic_call_info_t::add_events_to_path (checker_path *emission_path,
   if (m_is_returning_call)
     emission_path->add_event
       (make_unique<return_event> (eedge,
-				  (m_dynamic_call
-				   ? m_dynamic_call->location
-				   : UNKNOWN_LOCATION),
-				  dest_point.get_fndecl (),
-				  dest_stack_depth));
+				  event_loc_info (m_dynamic_call
+						  ? m_dynamic_call->location
+						  : UNKNOWN_LOCATION,
+						  dest_point.get_fndecl (),
+						  dest_stack_depth)));
   else
     emission_path->add_event
       (make_unique<call_event> (eedge,
-				(m_dynamic_call
-				 ? m_dynamic_call->location
-				 : UNKNOWN_LOCATION),
-				src_point.get_fndecl (),
-				src_stack_depth));
+				event_loc_info (m_dynamic_call
+						? m_dynamic_call->location
+						: UNKNOWN_LOCATION,
+						src_point.get_fndecl (),
+						src_stack_depth)));
 }
 
 /* class rewind_info_t : public custom_edge_info.  */
@@ -2103,14 +2103,18 @@ rewind_info_t::add_events_to_path (checker_path *emission_path,
 
   emission_path->add_event
     (make_unique<rewind_from_longjmp_event>
-     (&eedge, get_longjmp_call ()->location,
-      src_point.get_fndecl (),
-      src_stack_depth, this));
+     (&eedge,
+      event_loc_info (get_longjmp_call ()->location,
+		      src_point.get_fndecl (),
+		      src_stack_depth),
+      this));
   emission_path->add_event
     (make_unique<rewind_to_setjmp_event>
-     (&eedge, get_setjmp_call ()->location,
-      dst_point.get_fndecl (),
-      dst_stack_depth, this));
+     (&eedge,
+      event_loc_info (get_setjmp_call ()->location,
+		      dst_point.get_fndecl (),
+		      dst_stack_depth),
+      this));
 }
 
 /* class exploded_edge : public dedge<eg_traits>.  */
@@ -2651,9 +2655,9 @@ mark_params_as_tainted (program_state *state, tree fndecl,
 class tainted_args_function_custom_event : public custom_event
 {
 public:
-  tainted_args_function_custom_event (location_t loc, tree fndecl, int depth)
-  : custom_event (loc, fndecl, depth),
-    m_fndecl (fndecl)
+  tainted_args_function_custom_event (const event_loc_info &loc_info)
+  : custom_event (loc_info),
+    m_fndecl (loc_info.m_fndecl)
   {
   }
 
@@ -2697,7 +2701,7 @@ public:
   {
     emission_path->add_event
       (make_unique<tainted_args_function_custom_event>
-       (DECL_SOURCE_LOCATION (m_fndecl), m_fndecl, 0));
+       (event_loc_info (DECL_SOURCE_LOCATION (m_fndecl), m_fndecl, 0)));
   }
 
 private:
@@ -3069,7 +3073,7 @@ class tainted_args_field_custom_event : public custom_event
 {
 public:
   tainted_args_field_custom_event (tree field)
-  : custom_event (DECL_SOURCE_LOCATION (field), NULL_TREE, 0),
+  : custom_event (event_loc_info (DECL_SOURCE_LOCATION (field), NULL_TREE, 0)),
     m_field (field)
   {
   }
@@ -3093,9 +3097,9 @@ private:
 class tainted_args_callback_custom_event : public custom_event
 {
 public:
-  tainted_args_callback_custom_event (location_t loc, tree fndecl, int depth,
-				 tree field)
-  : custom_event (loc, fndecl, depth),
+  tainted_args_callback_custom_event (const event_loc_info &loc_info,
+				      tree field)
+  : custom_event (loc_info),
     m_field (field)
   {
   }
@@ -3148,8 +3152,9 @@ public:
        "(2) function 'gadget_dev_desc_UDC_store' used as initializer
        for field 'store' marked with '__attribute__((tainted_args))'".  */
     emission_path->add_event
-      (make_unique<tainted_args_callback_custom_event> (m_loc, m_fndecl,
-							0, m_field));
+      (make_unique<tainted_args_callback_custom_event>
+       (event_loc_info (m_loc, m_fndecl, 0),
+	m_field));
   }
 
 private:
diff --git a/gcc/analyzer/infinite-recursion.cc b/gcc/analyzer/infinite-recursion.cc
index 7055926b156..1a17d31fa7b 100644
--- a/gcc/analyzer/infinite-recursion.cc
+++ b/gcc/analyzer/infinite-recursion.cc
@@ -191,9 +191,10 @@ public:
     gcc_assert (m_new_entry_enode);
     emission_path->add_event
       (make_unique<warning_event>
-       (m_new_entry_enode->get_supernode ()->get_start_location (),
-	m_callee_fndecl,
-	m_new_entry_enode->get_stack_depth (),
+       (event_loc_info (m_new_entry_enode->get_supernode
+			  ()->get_start_location (),
+			m_callee_fndecl,
+			m_new_entry_enode->get_stack_depth ()),
 	NULL, NULL, NULL));
   }
 
diff --git a/gcc/analyzer/pending-diagnostic.cc b/gcc/analyzer/pending-diagnostic.cc
index babefc5ad4e..5ff32c09511 100644
--- a/gcc/analyzer/pending-diagnostic.cc
+++ b/gcc/analyzer/pending-diagnostic.cc
@@ -192,11 +192,11 @@ pending_diagnostic::add_call_event (const exploded_edge &eedge,
   const gimple *last_stmt = src_point.get_supernode ()->get_last_stmt ();
   emission_path->add_event
     (make_unique<call_event> (eedge,
-			      (last_stmt
-			       ? last_stmt->location
-			       : UNKNOWN_LOCATION),
-			      src_point.get_fndecl (),
-			      src_stack_depth));
+			      event_loc_info (last_stmt
+					      ? last_stmt->location
+					      : UNKNOWN_LOCATION,
+					      src_point.get_fndecl (),
+					      src_stack_depth)));
 }
 
 /* Base implementation of pending_diagnostic::add_region_creation_events.
@@ -205,18 +205,16 @@ pending_diagnostic::add_call_event (const exploded_edge &eedge,
 void
 pending_diagnostic::add_region_creation_events (const region *reg,
 						tree capacity,
-						location_t loc,
-						tree fndecl, int depth,
+						const event_loc_info &loc_info,
 						checker_path &emission_path)
 {
   emission_path.add_event
     (make_unique<region_creation_event_memory_space> (reg->get_memory_space (),
-						      loc, fndecl, depth));
+						      loc_info));
 
   if (capacity)
     emission_path.add_event
-      (make_unique<region_creation_event_capacity> (capacity,
-						    loc, fndecl, depth));
+      (make_unique<region_creation_event_capacity> (capacity, loc_info));
 }
 
 /* Base implementation of pending_diagnostic::add_final_event.
@@ -230,11 +228,11 @@ pending_diagnostic::add_final_event (const state_machine *sm,
 				     checker_path *emission_path)
 {
   emission_path->add_event
-    (make_unique<warning_event> (get_stmt_location (stmt,
-						    enode->get_function ()),
-				 enode->get_function ()->decl,
-				 enode->get_stack_depth (),
-				 sm, var, state));
+    (make_unique<warning_event>
+     (event_loc_info (get_stmt_location (stmt, enode->get_function ()),
+		      enode->get_function ()->decl,
+		      enode->get_stack_depth ()),
+      sm, var, state));
 }
 
 } // namespace ana
diff --git a/gcc/analyzer/pending-diagnostic.h b/gcc/analyzer/pending-diagnostic.h
index 4bc3080c049..be446a4ac02 100644
--- a/gcc/analyzer/pending-diagnostic.h
+++ b/gcc/analyzer/pending-diagnostic.h
@@ -315,8 +315,7 @@ class pending_diagnostic
      See the comment for class region_creation_event.  */
   virtual void add_region_creation_events (const region *reg,
 					   tree capacity,
-					   location_t loc,
-					   tree fndecl, int depth,
+					   const event_loc_info &loc_info,
 					   checker_path &emission_path);
 
   /* Vfunc for adding the final warning_event to a checker_path, so that e.g.
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index c6486f315f4..d00f15f468f 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -2849,13 +2849,11 @@ public:
   void
   add_region_creation_events (const region *,
 			      tree capacity,
-			      location_t loc,
-			      tree fndecl, int depth,
+			      const event_loc_info &loc_info,
 			      checker_path &emission_path) final override
   {
     emission_path.add_event
-      (make_unique<region_creation_event_allocation_size> (capacity,
-							   loc, fndecl, depth));
+      (make_unique<region_creation_event_allocation_size> (capacity, loc_info));
 
     m_has_allocation_event = true;
   }
diff --git a/gcc/analyzer/sm-signal.cc b/gcc/analyzer/sm-signal.cc
index 87e21a41715..38db6c0228a 100644
--- a/gcc/analyzer/sm-signal.cc
+++ b/gcc/analyzer/sm-signal.cc
@@ -235,7 +235,7 @@ public:
   {
     emission_path->add_event
       (make_unique<precanned_custom_event>
-       (UNKNOWN_LOCATION, NULL_TREE, 0,
+       (event_loc_info (UNKNOWN_LOCATION, NULL_TREE, 0),
 	"later on,"
 	" when the signal is delivered to the process"));
   }
diff --git a/gcc/analyzer/varargs.cc b/gcc/analyzer/varargs.cc
index daa937d9c65..519b32d693a 100644
--- a/gcc/analyzer/varargs.cc
+++ b/gcc/analyzer/varargs.cc
@@ -777,9 +777,9 @@ public:
     {
     public:
       va_arg_call_event (const exploded_edge &eedge,
-			 location_t loc, tree fndecl, int depth,
+			 const event_loc_info &loc_info,
 			 int num_variadic_arguments)
-      : call_event (eedge, loc, fndecl, depth),
+      : call_event (eedge, loc_info),
 	m_num_variadic_arguments (num_variadic_arguments)
       {
       }
@@ -812,13 +812,12 @@ public:
 	  = get_num_variadic_arguments (dst_node->get_function ()->decl,
 					call_stmt);
 	emission_path->add_event
-	  (make_unique<va_arg_call_event> (eedge,
-					   (last_stmt
-					    ? last_stmt->location
-					    : UNKNOWN_LOCATION),
-					   src_point.get_fndecl (),
-					   src_stack_depth,
-					   num_variadic_arguments));
+	  (make_unique<va_arg_call_event>
+	   (eedge,
+	    event_loc_info (last_stmt ? last_stmt->location : UNKNOWN_LOCATION,
+			    src_point.get_fndecl (),
+			    src_stack_depth),
+	    num_variadic_arguments));
       }
     else
       pending_diagnostic::add_call_event (eedge, emission_path);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-02 21:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 21:32 [gcc r13-4472] analyzer: introduce struct event_loc_info David Malcolm

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).