void
diagnostic_manager::add_diagnostic (const state_machine *sm,
- const exploded_node *enode,
+ exploded_node *enode,
const supernode *snode, const gimple *stmt,
stmt_finder *finder,
tree var,
= new saved_diagnostic (sm, enode, snode, stmt, finder, var, sval,
state, d, m_saved_diagnostics.length ());
m_saved_diagnostics.safe_push (sd);
+ enode->add_diagnostic (sd);
if (get_logger ())
- log ("adding saved diagnostic %i at SN %i: %qs",
+ log ("adding saved diagnostic %i at SN %i to EN %i: %qs",
sd->get_index (),
- snode->m_index, d->get_kind ());
+ snode->m_index, enode->m_index, d->get_kind ());
}
/* Queue pending_diagnostic D at ENODE for later emission. */
void
-diagnostic_manager::add_diagnostic (const exploded_node *enode,
+diagnostic_manager::add_diagnostic (exploded_node *enode,
const supernode *snode, const gimple *stmt,
stmt_finder *finder,
pending_diagnostic *d)
json::object *to_json () const;
void add_diagnostic (const state_machine *sm,
- const exploded_node *enode,
+ exploded_node *enode,
const supernode *snode, const gimple *stmt,
stmt_finder *finder,
tree var,
state_machine::state_t state,
pending_diagnostic *d);
- void add_diagnostic (const exploded_node *enode,
+ void add_diagnostic (exploded_node *enode,
const supernode *snode, const gimple *stmt,
stmt_finder *finder,
pending_diagnostic *d);
impl_region_model_context::
impl_region_model_context (exploded_graph &eg,
- const exploded_node *enode_for_diag,
+ exploded_node *enode_for_diag,
const program_state *old_state,
program_state *new_state,
const gimple *stmt,
impl_sm_context (exploded_graph &eg,
int sm_idx,
const state_machine &sm,
- const exploded_node *enode_for_diag,
+ exploded_node *enode_for_diag,
const program_state *old_state,
program_state *new_state,
const sm_state_map *old_smap,
log_user m_logger;
exploded_graph &m_eg;
- const exploded_node *m_enode_for_diag;
+ exploded_node *m_enode_for_diag;
const program_state *m_old_state;
program_state *m_new_state;
const sm_state_map *m_old_smap;
dump_processed_stmts (pp);
}
- dump_saved_diagnostics (pp, args.m_eg.get_diagnostic_manager ());
+ dump_saved_diagnostics (pp);
args.dump_extra_info (this, pp);
/* Dump any saved_diagnostics at this enode to PP. */
void
-exploded_node::dump_saved_diagnostics (pretty_printer *pp,
- const diagnostic_manager &dm) const
+exploded_node::dump_saved_diagnostics (pretty_printer *pp) const
{
- for (unsigned i = 0; i < dm.get_num_diagnostics (); i++)
+ unsigned i;
+ const saved_diagnostic *sd;
+ FOR_EACH_VEC_ELT (m_saved_diagnostics, i, sd)
{
- const saved_diagnostic *sd = dm.get_saved_diagnostic (i);
- if (sd->m_enode == this)
- {
- pp_printf (pp, "DIAGNOSTIC: %s (sd: %i)",
- sd->m_d->get_kind (), sd->get_index ());
- pp_newline (pp);
- }
+ pp_printf (pp, "DIAGNOSTIC: %s (sd: %i)",
+ sd->m_d->get_kind (), sd->get_index ());
+ pp_newline (pp);
}
}
exploded_node::on_stmt (exploded_graph &eg,
const supernode *snode,
const gimple *stmt,
- program_state *state) const
+ program_state *state)
{
logger *logger = eg.get_logger ();
LOG_SCOPE (logger);
exploded_node::on_edge (exploded_graph &eg,
const superedge *succ,
program_point *next_point,
- program_state *next_state) const
+ program_state *next_state)
{
LOG_FUNC (eg.get_logger ());
if (!next_point->on_edge (eg, succ))
return false;
- if (!next_state->on_edge (eg, *this, succ))
+ if (!next_state->on_edge (eg, this, succ))
return false;
return true;
exploded_node::on_longjmp (exploded_graph &eg,
const gcall *longjmp_call,
program_state *new_state,
- region_model_context *ctxt) const
+ region_model_context *ctxt)
{
tree buf_ptr = gimple_call_arg (longjmp_call, 0);
gcc_assert (POINTER_TYPE_P (TREE_TYPE (buf_ptr)));
leaks. */
void
-exploded_node::detect_leaks (exploded_graph &eg) const
+exploded_node::detect_leaks (exploded_graph &eg)
{
LOG_FUNC_1 (eg.get_logger (), "EN: %i", m_index);
exploded_node *
exploded_graph::get_or_create_node (const program_point &point,
const program_state &state,
- const exploded_node *enode_for_diag)
+ exploded_node *enode_for_diag)
{
logger * const logger = get_logger ();
LOG_FUNC (logger);
break;
}
gv->end_tdtr ();
+
/* Dump any saved_diagnostics at this enode. */
- {
- const diagnostic_manager &dm = m_eg.get_diagnostic_manager ();
- for (unsigned i = 0; i < dm.get_num_diagnostics (); i++)
- {
- const saved_diagnostic *sd = dm.get_saved_diagnostic (i);
- if (sd->m_enode == enode)
- print_saved_diagnostic (gv, sd);
- }
- }
+ for (unsigned i = 0; i < enode->get_num_diagnostics (); i++)
+ {
+ const saved_diagnostic *sd = enode->get_saved_diagnostic (i);
+ print_saved_diagnostic (gv, sd);
+ }
pp_printf (pp, "</TABLE>");
pp_printf (pp, "</TD>");
}
{
public:
impl_region_model_context (exploded_graph &eg,
- const exploded_node *enode_for_diag,
+ exploded_node *enode_for_diag,
/* TODO: should we be getting the ECs from the
old state, rather than the new? */
exploded_graph *m_eg;
log_user m_logger;
- const exploded_node *m_enode_for_diag;
+ exploded_node *m_enode_for_diag;
const program_state *m_old_state;
program_state *m_new_state;
const gimple *m_stmt;
void dump (const extrinsic_state &ext_state) const;
void dump_processed_stmts (pretty_printer *pp) const;
- void dump_saved_diagnostics (pretty_printer *pp,
- const diagnostic_manager &dm) const;
+ void dump_saved_diagnostics (pretty_printer *pp) const;
json::object *to_json (const extrinsic_state &ext_state) const;
on_stmt_flags on_stmt (exploded_graph &eg,
const supernode *snode,
const gimple *stmt,
- program_state *state) const;
+ program_state *state);
bool on_edge (exploded_graph &eg,
const superedge *succ,
program_point *next_point,
- program_state *next_state) const;
+ program_state *next_state);
void on_longjmp (exploded_graph &eg,
const gcall *call,
program_state *new_state,
- region_model_context *ctxt) const;
+ region_model_context *ctxt);
- void detect_leaks (exploded_graph &eg) const;
+ void detect_leaks (exploded_graph &eg);
const program_point &get_point () const { return m_ps.get_point (); }
const supernode *get_supernode () const
m_status = status;
}
+ void add_diagnostic (const saved_diagnostic *sd)
+ {
+ m_saved_diagnostics.safe_push (sd);
+ }
+ unsigned get_num_diagnostics () const
+ {
+ return m_saved_diagnostics.length ();
+ }
+ const saved_diagnostic *get_saved_diagnostic (unsigned idx) const
+ {
+ return m_saved_diagnostics[idx];
+ }
+
private:
DISABLE_COPY_AND_ASSIGN (exploded_node);
enum status m_status;
+ /* The saved_diagnostics at this enode, borrowed from the
+ diagnostic_manager. */
+ auto_vec <const saved_diagnostic *> m_saved_diagnostics;
+
public:
/* The index of this exploded_node. */
const int m_index;
exploded_node *get_or_create_node (const program_point &point,
const program_state &state,
- const exploded_node *enode_for_diag);
+ exploded_node *enode_for_diag);
exploded_edge *add_edge (exploded_node *src, exploded_node *dest,
const superedge *sedge,
exploded_edge::custom_info_t *custom = NULL);
void
feasible_node::dump_dot (graphviz_out *gv,
- const dump_args_t &args) const
+ const dump_args_t &) const
{
pretty_printer *pp = gv->get_pp ();
pp_newline (pp);
m_inner_node->dump_processed_stmts (pp);
- m_inner_node->dump_saved_diagnostics
- (pp, args.m_inner_args.m_eg.get_diagnostic_manager ());
+ m_inner_node->dump_saved_diagnostics (pp);
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
bool
program_state::on_edge (exploded_graph &eg,
- const exploded_node &enode,
+ exploded_node *enode,
const superedge *succ)
{
/* Update state. */
- const program_point &point = enode.get_point ();
+ const program_point &point = enode->get_point ();
const gimple *last_stmt = point.get_supernode ()->get_last_stmt ();
/* For conditionals and switch statements, add the
sm-state transitions (e.g. transitions due to ptrs becoming known
to be NULL or non-NULL) */
- impl_region_model_context ctxt (eg, &enode,
- &enode.get_state (),
+ impl_region_model_context ctxt (eg, enode,
+ &enode->get_state (),
this,
last_stmt);
if (!m_region_model->maybe_update_for_edge (*succ,
return false;
}
- program_state::detect_leaks (enode.get_state (), *this,
+ program_state::detect_leaks (enode->get_state (), *this,
NULL, eg.get_ext_state (),
&ctxt);
program_state
program_state::prune_for_point (exploded_graph &eg,
const program_point &point,
- const exploded_node *enode_for_diag) const
+ exploded_node *enode_for_diag) const
{
logger * const logger = eg.get_logger ();
LOG_SCOPE (logger);
function * get_current_function () const;
bool on_edge (exploded_graph &eg,
- const exploded_node &enode,
+ exploded_node *enode,
const superedge *succ);
program_state prune_for_point (exploded_graph &eg,
const program_point &point,
- const exploded_node *enode_for_diag) const;
+ exploded_node *enode_for_diag) const;
tree get_representative_tree (const svalue *sval) const;