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>
This commit is contained in:
David Malcolm 2022-11-03 13:47:01 -04:00
parent 6341f14e36
commit 2a9b395b1e
4 changed files with 12 additions and 13 deletions

View file

@ -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);

View file

@ -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);

View file

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

View file

@ -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;
};