public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3630] analyzer: use std::unique_ptr for saved_diagnostic::m_stmt_finder
@ 2022-11-03 17:48 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-11-03 17:48 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2a9b395b1e4542c79b250b756346816a9b72d859
commit r13-3630-g2a9b395b1e4542c79b250b756346816a9b72d859
Author: David Malcolm <dmalcolm@redhat.com>
Date: Thu Nov 3 13:47:01 2022 -0400
analyzer: use std::unique_ptr for saved_diagnostic::m_stmt_finder
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>
Diff:
---
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;
};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-03 17:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 17:48 [gcc r13-3630] analyzer: use std::unique_ptr for saved_diagnostic::m_stmt_finder 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).