public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [committed 2/8] analyzer: use std::unique_ptr for saved_diagnostic::m_stmt_finder
Date: Thu,  3 Nov 2022 13:51:29 -0400	[thread overview]
Message-ID: <20221103175135.2269543-3-dmalcolm@redhat.com> (raw)
In-Reply-To: <20221103175135.2269543-1-dmalcolm@redhat.com>

gcc/analyzer/ChangeLog:
	* diagnostic-manager.cc (saved_diagnostic::saved_diagnostic): Make
	stmt_finder const.
	(saved_diagnostic::~saved_diagnostic): Remove explicit delete of
	m_stmt_finder.
	(diagnostic_manager::add_diagnostic): Make stmt_finder const.
	* diagnostic-manager.h (saved_diagnostic::saved_diagnostic):
	Likewise.
	(saved_diagnostic::m_stmt_finder): Convert to std::unique_ptr.
	(diagnostic_manager::add_diagnostic): Make stmt_finder const.
	* engine.cc (impl_sm_context::impl_sm_context): Likewise.
	(impl_sm_context::m_stmt_finder): Likewise.
	(leak_stmt_finder::clone): Convert return type to std::unique_ptr.
	* exploded-graph.h (stmt_finder::clone): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/analyzer/diagnostic-manager.cc | 7 +++----
 gcc/analyzer/diagnostic-manager.h  | 8 ++++----
 gcc/analyzer/engine.cc             | 8 ++++----
 gcc/analyzer/exploded-graph.h      | 2 +-
 4 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index 0444e52258c..bb8584a1e0b 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -635,7 +635,7 @@ epath_finder::dump_feasible_path (const exploded_node *target_enode,
 saved_diagnostic::saved_diagnostic (const state_machine *sm,
 				    const exploded_node *enode,
 				    const supernode *snode, const gimple *stmt,
-				    stmt_finder *stmt_finder,
+				    const stmt_finder *stmt_finder,
 				    tree var,
 				    const svalue *sval,
 				    state_machine::state_t state,
@@ -662,7 +662,6 @@ saved_diagnostic::saved_diagnostic (const state_machine *sm,
 
 saved_diagnostic::~saved_diagnostic ()
 {
-  delete m_stmt_finder;
   delete m_best_epath;
   delete m_problem;
 }
@@ -961,7 +960,7 @@ bool
 diagnostic_manager::add_diagnostic (const state_machine *sm,
 				    exploded_node *enode,
 				    const supernode *snode, const gimple *stmt,
-				    stmt_finder *finder,
+				    const stmt_finder *finder,
 				    tree var,
 				    const svalue *sval,
 				    state_machine::state_t state,
@@ -1010,7 +1009,7 @@ diagnostic_manager::add_diagnostic (const state_machine *sm,
 bool
 diagnostic_manager::add_diagnostic (exploded_node *enode,
 				    const supernode *snode, const gimple *stmt,
-				    stmt_finder *finder,
+				    const stmt_finder *finder,
 				    std::unique_ptr<pending_diagnostic> d)
 {
   gcc_assert (enode);
diff --git a/gcc/analyzer/diagnostic-manager.h b/gcc/analyzer/diagnostic-manager.h
index fdab038d7a1..c87f2159753 100644
--- a/gcc/analyzer/diagnostic-manager.h
+++ b/gcc/analyzer/diagnostic-manager.h
@@ -33,7 +33,7 @@ public:
   saved_diagnostic (const state_machine *sm,
 		    const exploded_node *enode,
 		    const supernode *snode, const gimple *stmt,
-		    stmt_finder *stmt_finder,
+		    const stmt_finder *stmt_finder,
 		    tree var, const svalue *sval,
 		    state_machine::state_t state,
 		    std::unique_ptr<pending_diagnostic> d,
@@ -72,7 +72,7 @@ public:
   const exploded_node *m_enode;
   const supernode *m_snode;
   const gimple *m_stmt;
-  stmt_finder *m_stmt_finder;
+  std::unique_ptr<stmt_finder> m_stmt_finder;
   tree m_var;
   const svalue *m_sval;
   state_machine::state_t m_state;
@@ -113,7 +113,7 @@ public:
   bool add_diagnostic (const state_machine *sm,
 		       exploded_node *enode,
 		       const supernode *snode, const gimple *stmt,
-		       stmt_finder *finder,
+		       const stmt_finder *finder,
 		       tree var,
 		       const svalue *sval,
 		       state_machine::state_t state,
@@ -121,7 +121,7 @@ public:
 
   bool add_diagnostic (exploded_node *enode,
 		       const supernode *snode, const gimple *stmt,
-		       stmt_finder *finder,
+		       const stmt_finder *finder,
 		       std::unique_ptr<pending_diagnostic> d);
 
   void add_note (std::unique_ptr<pending_note> pn);
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index fd532b1384d..553957ad982 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -282,7 +282,7 @@ public:
 		   const sm_state_map *old_smap,
 		   sm_state_map *new_smap,
 		   path_context *path_ctxt,
-		   stmt_finder *stmt_finder = NULL,
+		   const stmt_finder *stmt_finder = NULL,
 		   bool unknown_side_effects = false)
   : sm_context (sm_idx, sm),
     m_logger (eg.get_logger ()),
@@ -523,7 +523,7 @@ public:
   const sm_state_map *m_old_smap;
   sm_state_map *m_new_smap;
   path_context *m_path_ctxt;
-  stmt_finder *m_stmt_finder;
+  const stmt_finder *m_stmt_finder;
 
   /* Are we handling an external function with unknown side effects?  */
   bool m_unknown_side_effects;
@@ -538,9 +538,9 @@ public:
   leak_stmt_finder (const exploded_graph &eg, tree var)
   : m_eg (eg), m_var (var) {}
 
-  stmt_finder *clone () const final override
+  std::unique_ptr<stmt_finder> clone () const final override
   {
-    return new leak_stmt_finder (m_eg, m_var);
+    return make_unique<leak_stmt_finder> (m_eg, m_var);
   }
 
   const gimple *find_stmt (const exploded_path &epath)
diff --git a/gcc/analyzer/exploded-graph.h b/gcc/analyzer/exploded-graph.h
index dae73daf54a..7947f50cdd7 100644
--- a/gcc/analyzer/exploded-graph.h
+++ b/gcc/analyzer/exploded-graph.h
@@ -991,7 +991,7 @@ class stmt_finder
 {
 public:
   virtual ~stmt_finder () {}
-  virtual stmt_finder *clone () const = 0;
+  virtual std::unique_ptr<stmt_finder> clone () const = 0;
   virtual const gimple *find_stmt (const exploded_path &epath) = 0;
 };
 
-- 
2.26.3


  parent reply	other threads:[~2022-11-03 17:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 17:51 [committed 0/8] Use std::unique_ptr in analyzer David Malcolm
2022-11-03 17:51 ` [committed 1/8] analyzer: use std::unique_ptr for pending_diagnostic/note David Malcolm
2022-11-03 17:51 ` David Malcolm [this message]
2022-11-03 17:51 ` [committed 3/8] analyzer: use std::unique_ptr for custom_edge_info pointers David Malcolm
2022-11-03 17:51 ` [committed 4/8] analyzer: use std::unique_ptr for feasibility_problems and exploded_path David Malcolm
2022-11-03 17:51 ` [committed 5/8] analyzer: use std::unique_ptr for checker_event David Malcolm
2022-11-03 17:51 ` [committed 6/8] analyzer: use std::unique_ptr during bifurcation David Malcolm
2022-11-03 17:51 ` [committed 7/8] analyzer: use std::unique_ptr for known functions David Malcolm
2022-11-03 17:51 ` [committed 8/8] analyzer: use std::unique_ptr for state machines from plugins David Malcolm

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=20221103175135.2269543-3-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@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: link
Be 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).