}
feasibility_state succ_state (fnode->get_state ());
- rejected_constraint *rc = NULL;
+ std::unique_ptr<rejected_constraint> rc;
if (succ_state.maybe_update_for_edge (logger, succ_eedge, &rc))
{
gcc_assert (rc == NULL);
gcc_assert (rc);
fg->add_feasibility_problem (fnode,
succ_eedge,
- rc);
+ std::move (rc));
/* Give up if there have been too many infeasible edges. */
if (fg->get_num_infeasible ()
eedge->m_src->m_index,
eedge->m_dest->m_index);
- rejected_constraint *rc = NULL;
+ std::unique_ptr <rejected_constraint> rc;
if (!state.maybe_update_for_edge (logger, eedge, &rc))
{
gcc_assert (rc);
const program_point &src_point = src_enode.get_point ();
const gimple *last_stmt
= src_point.get_supernode ()->get_last_stmt ();
- *out = make_unique<feasibility_problem> (edge_idx, *eedge,
- last_stmt, rc);
+ *out = ::make_unique<feasibility_problem> (edge_idx, *eedge,
+ last_stmt,
+ std::move (rc));
}
- else
- delete rc;
return false;
}
Otherwise, return false and write to *OUT_RC. */
bool
-feasibility_state::maybe_update_for_edge (logger *logger,
- const exploded_edge *eedge,
- rejected_constraint **out_rc)
+feasibility_state::
+maybe_update_for_edge (logger *logger,
+ const exploded_edge *eedge,
+ std::unique_ptr<rejected_constraint> *out_rc)
{
const exploded_node &src_enode = *eedge->m_src;
const program_point &src_point = src_enode.get_point ();
feasibility_problem (unsigned eedge_idx,
const exploded_edge &eedge,
const gimple *last_stmt,
- rejected_constraint *rc)
+ std::unique_ptr<rejected_constraint> rc)
: m_eedge_idx (eedge_idx), m_eedge (eedge),
- m_last_stmt (last_stmt), m_rc (rc)
+ m_last_stmt (last_stmt), m_rc (std::move (rc))
{}
- ~feasibility_problem () { delete m_rc; }
void dump_to_pp (pretty_printer *pp) const;
unsigned m_eedge_idx;
const exploded_edge &m_eedge;
const gimple *m_last_stmt;
- rejected_constraint *m_rc;
+ std::unique_ptr<rejected_constraint> m_rc;
};
/* A class for capturing the state of a node when checking a path
bool maybe_update_for_edge (logger *logger,
const exploded_edge *eedge,
- rejected_constraint **out_rc);
+ std::unique_ptr<rejected_constraint> *out_rc);
void update_for_stmt (const gimple *stmt);
const region_model &get_model () const { return m_model; }
}
/* Add an infeasible_node to this graph and an infeasible_edge connecting
- to it from SRC_FNODE, capturing a failure of RC along EEDGE.
- Takes ownership of RC. */
+ to it from SRC_FNODE, capturing a failure of RC along EEDGE. */
void
feasible_graph::add_feasibility_problem (feasible_node *src_fnode,
const exploded_edge *eedge,
- rejected_constraint *rc)
+ std::unique_ptr<rejected_constraint> rc)
{
infeasible_node *dst_fnode
- = new infeasible_node (eedge->m_dest, m_nodes.length (), rc);
+ = new infeasible_node (eedge->m_dest, m_nodes.length (), std::move (rc));
digraph<fg_traits>::add_node (dst_fnode);
add_edge (new infeasible_edge (src_fnode, dst_fnode, eedge));
m_num_infeasible++;
{
public:
infeasible_node (const exploded_node *inner_node, unsigned index,
- rejected_constraint *rc)
+ std::unique_ptr<rejected_constraint> rc)
: base_feasible_node (inner_node, index),
- m_rc (rc)
+ m_rc (std::move (rc))
{
}
- ~infeasible_node () { delete m_rc; }
void dump_dot (graphviz_out *gv,
const dump_args_t &args) const final override;
private:
- rejected_constraint *m_rc;
+ std::unique_ptr<rejected_constraint> m_rc;
};
/* Base class of edge within a feasible_graph. */
void add_feasibility_problem (feasible_node *src_fnode,
const exploded_edge *eedge,
- rejected_constraint *rc);
+ std::unique_ptr<rejected_constraint> rc);
std::unique_ptr<exploded_path> make_epath (feasible_node *fnode) const;
bool
region_model::add_constraint (tree lhs, enum tree_code op, tree rhs,
region_model_context *ctxt,
- rejected_constraint **out)
+ std::unique_ptr<rejected_constraint> *out)
{
bool sat = add_constraint (lhs, op, rhs, ctxt);
if (!sat && out)
- *out = new rejected_op_constraint (*this, lhs, op, rhs);
+ *out = make_unique <rejected_op_constraint> (*this, lhs, op, rhs);
return sat;
}
region_model::maybe_update_for_edge (const superedge &edge,
const gimple *last_stmt,
region_model_context *ctxt,
- rejected_constraint **out)
+ std::unique_ptr<rejected_constraint> *out)
{
/* Handle frame updates for interprocedural edges. */
switch (edge.m_kind)
to it. */
bool
-region_model::apply_constraints_for_gcond (const cfg_superedge &sedge,
- const gcond *cond_stmt,
- region_model_context *ctxt,
- rejected_constraint **out)
+region_model::
+apply_constraints_for_gcond (const cfg_superedge &sedge,
+ const gcond *cond_stmt,
+ region_model_context *ctxt,
+ std::unique_ptr<rejected_constraint> *out)
{
::edge cfg_edge = sedge.get_cfg_edge ();
gcc_assert (cfg_edge != NULL);
to it. */
bool
-region_model::apply_constraints_for_gswitch (const switch_cfg_superedge &edge,
- const gswitch *switch_stmt,
- region_model_context *ctxt,
- rejected_constraint **out)
+region_model::
+apply_constraints_for_gswitch (const switch_cfg_superedge &edge,
+ const gswitch *switch_stmt,
+ region_model_context *ctxt,
+ std::unique_ptr<rejected_constraint> *out)
{
tree index = gimple_switch_index (switch_stmt);
const svalue *index_sval = get_rvalue (index, ctxt);
&& !ctxt->possibly_tainted_p (index_sval))
{
if (out)
- *out = new rejected_default_case (*this);
+ *out = make_unique <rejected_default_case> (*this);
return false;
}
= ranges_mgr->get_or_create_ranges_for_switch (&edge, switch_stmt);
bool sat = m_constraints->add_bounded_ranges (index_sval, all_cases_ranges);
if (!sat && out)
- *out = new rejected_ranges_constraint (*this, index, all_cases_ranges);
+ *out = make_unique <rejected_ranges_constraint> (*this, index, all_cases_ranges);
if (sat && ctxt && !all_cases_ranges->empty_p ())
ctxt->on_bounded_ranges (*index_sval, *all_cases_ranges);
return sat;
to it. */
bool
-region_model::apply_constraints_for_exception (const gimple *last_stmt,
- region_model_context *ctxt,
- rejected_constraint **out)
+region_model::
+apply_constraints_for_exception (const gimple *last_stmt,
+ region_model_context *ctxt,
+ std::unique_ptr<rejected_constraint> *out)
{
gcc_assert (last_stmt);
if (const gcall *call = dyn_cast <const gcall *> (last_stmt))
bool maybe_update_for_edge (const superedge &edge,
const gimple *last_stmt,
region_model_context *ctxt,
- rejected_constraint **out);
+ std::unique_ptr<rejected_constraint> *out);
void update_for_gcall (const gcall *call_stmt,
region_model_context *ctxt,
region_model_context *ctxt);
bool add_constraint (tree lhs, enum tree_code op, tree rhs,
region_model_context *ctxt,
- rejected_constraint **out);
+ std::unique_ptr<rejected_constraint> *out);
const region *
get_or_create_region_for_heap_alloc (const svalue *size_in_bytes,
bool apply_constraints_for_gcond (const cfg_superedge &edge,
const gcond *cond_stmt,
region_model_context *ctxt,
- rejected_constraint **out);
+ std::unique_ptr<rejected_constraint> *out);
bool apply_constraints_for_gswitch (const switch_cfg_superedge &edge,
const gswitch *switch_stmt,
region_model_context *ctxt,
- rejected_constraint **out);
+ std::unique_ptr<rejected_constraint> *out);
bool apply_constraints_for_ggoto (const cfg_superedge &edge,
const ggoto *goto_stmt,
region_model_context *ctxt);
bool apply_constraints_for_exception (const gimple *last_stmt,
region_model_context *ctxt,
- rejected_constraint **out);
+ std::unique_ptr<rejected_constraint> *out);
int poison_any_pointers_to_descendents (const region *reg,
enum poison_kind pkind);