#include "analyzer/feasible-graph.h"
#include "analyzer/checker-path.h"
#include "analyzer/reachability.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
logger *get_logger () const { return m_eg.get_logger (); }
- exploded_path *get_best_epath (const exploded_node *target_enode,
- const char *desc, unsigned diag_idx,
- feasibility_problem **out_problem);
+ std::unique_ptr<exploded_path>
+ get_best_epath (const exploded_node *target_enode,
+ const char *desc, unsigned diag_idx,
+ std::unique_ptr<feasibility_problem> *out_problem);
private:
DISABLE_COPY_AND_ASSIGN(epath_finder);
- exploded_path *explore_feasible_paths (const exploded_node *target_enode,
- const char *desc, unsigned diag_idx);
- bool process_worklist_item (feasible_worklist *worklist,
- const trimmed_graph &tg,
- feasible_graph *fg,
- const exploded_node *target_enode,
- unsigned diag_idx,
- exploded_path **out_best_path) const;
+ std::unique_ptr<exploded_path>
+ explore_feasible_paths (const exploded_node *target_enode,
+ const char *desc, unsigned diag_idx);
+ bool
+ process_worklist_item (feasible_worklist *worklist,
+ const trimmed_graph &tg,
+ feasible_graph *fg,
+ const exploded_node *target_enode,
+ unsigned diag_idx,
+ std::unique_ptr<exploded_path> *out_best_path) const;
void dump_trimmed_graph (const exploded_node *target_enode,
const char *desc, unsigned diag_idx,
const trimmed_graph &tg,
Write any feasibility_problem to *OUT_PROBLEM. */
-exploded_path *
+std::unique_ptr<exploded_path>
epath_finder::get_best_epath (const exploded_node *enode,
const char *desc, unsigned diag_idx,
- feasibility_problem **out_problem)
+ std::unique_ptr<feasibility_problem> *out_problem)
{
logger *logger = get_logger ();
LOG_SCOPE (logger);
/* Attempt to find the shortest feasible path using feasible_graph. */
if (logger)
logger->log ("trying to find shortest feasible path");
- if (exploded_path *epath = explore_feasible_paths (enode, desc, diag_idx))
+ if (std::unique_ptr<exploded_path> epath
+ = explore_feasible_paths (enode, desc, diag_idx))
{
if (logger)
logger->log ("accepting %qs at EN: %i, SN: %i (sd: %i)"
if (logger)
logger->log ("trying to find shortest path ignoring feasibility");
gcc_assert (m_sep);
- exploded_path *epath
- = new exploded_path (m_sep->get_shortest_path (enode));
+ std::unique_ptr<exploded_path> epath
+ = make_unique<exploded_path> (m_sep->get_shortest_path (enode));
if (epath->feasible_p (logger, out_problem, m_eg.get_engine (), &m_eg))
{
if (logger)
continue forever without reaching the target), or
- getting monotonically closer to the termination threshold. */
-exploded_path *
+std::unique_ptr<exploded_path>
epath_finder::explore_feasible_paths (const exploded_node *target_enode,
const char *desc, unsigned diag_idx)
{
a limit. */
/* Set this if we find a feasible path to TARGET_ENODE. */
- exploded_path *best_path = NULL;
+ std::unique_ptr<exploded_path> best_path = NULL;
{
auto_checking_feasibility sentinel (mgr);
to TARGET_ENODE. */
bool
-epath_finder::process_worklist_item (feasible_worklist *worklist,
- const trimmed_graph &tg,
- feasible_graph *fg,
- const exploded_node *target_enode,
- unsigned diag_idx,
- exploded_path **out_best_path) const
+epath_finder::
+process_worklist_item (feasible_worklist *worklist,
+ const trimmed_graph &tg,
+ feasible_graph *fg,
+ const exploded_node *target_enode,
+ unsigned diag_idx,
+ std::unique_ptr<exploded_path> *out_best_path) const
{
logger *logger = get_logger ();
gcc_assert (m_enode);
}
-/* saved_diagnostic's dtor. */
-
-saved_diagnostic::~saved_diagnostic ()
-{
- delete m_best_epath;
- delete m_problem;
-}
-
bool
saved_diagnostic::operator== (const saved_diagnostic &other) const
{
{
logger *logger = pf->get_logger ();
LOG_SCOPE (logger);
- delete m_best_epath;
- delete m_problem;
m_problem = NULL;
m_best_epath = pf->get_best_epath (m_enode, m_d->get_kind (), m_idx,
state_machine::state_t state,
std::unique_ptr<pending_diagnostic> d,
unsigned idx);
- ~saved_diagnostic ();
bool operator== (const saved_diagnostic &other) const;
const feasibility_problem *get_feasibility_problem () const
{
- return m_problem;
+ return m_problem.get ();
}
bool calc_best_epath (epath_finder *pf);
- const exploded_path *get_best_epath () const { return m_best_epath; }
+ const exploded_path *get_best_epath () const { return m_best_epath.get (); }
unsigned get_epath_length () const;
void add_duplicate (saved_diagnostic *other);
DISABLE_COPY_AND_ASSIGN (saved_diagnostic);
unsigned m_idx;
- exploded_path *m_best_epath; // owned
- feasibility_problem *m_problem; // owned
+ std::unique_ptr<exploded_path> m_best_epath;
+ std::unique_ptr<feasibility_problem> m_problem;
auto_vec<const saved_diagnostic *> m_duplicates;
auto_delete_vec <pending_note> m_notes;