/* Classes for saving, deduplicating, and emitting analyzer diagnostics.
- Copyright (C) 2019-2020 Free Software Foundation, Inc.
+ Copyright (C) 2019-2023 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
namespace ana {
+class epath_finder;
+
/* A to-be-emitted diagnostic stored within diagnostic_manager. */
class saved_diagnostic
{
public:
- enum status
- {
- STATUS_NEW,
- STATUS_INFEASIBLE_PATH,
- STATUS_FEASIBLE_PATH
- };
-
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,
- pending_diagnostic *d);
- ~saved_diagnostic ();
+ std::unique_ptr<pending_diagnostic> d,
+ unsigned idx);
bool operator== (const saved_diagnostic &other) const;
- void set_feasible ()
- {
- gcc_assert (m_status == STATUS_NEW);
- m_status = STATUS_FEASIBLE_PATH;
- }
- void set_infeasible (feasibility_problem *p)
- {
- gcc_assert (m_status == STATUS_NEW);
- m_status = STATUS_INFEASIBLE_PATH;
- m_problem = p; // take ownership
- }
+ void add_note (std::unique_ptr<pending_note> pn);
+
+ json::object *to_json () const;
+
+ void dump_dot_id (pretty_printer *pp) const;
+ void dump_as_dot_node (pretty_printer *pp) const;
+
const feasibility_problem *get_feasibility_problem () const
{
- return m_problem;
+ return m_problem.get ();
}
- enum status get_status () const { return m_status; }
+ bool calc_best_epath (epath_finder *pf);
+ const exploded_path *get_best_epath () const { return m_best_epath.get (); }
+ unsigned get_epath_length () const;
+
+ void add_duplicate (saved_diagnostic *other);
+ unsigned get_num_dupes () const { return m_duplicates.length (); }
+
+ unsigned get_index () const { return m_idx; }
+
+ bool supercedes_p (const saved_diagnostic &other) const;
- void set_epath_length (unsigned length) { m_epath_length = length; }
- unsigned get_epath_length () const { return m_epath_length; }
+ void emit_any_notes () const;
//private:
const state_machine *m_sm;
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;
- pending_diagnostic *m_d;
- exploded_edge *m_trailing_eedge;
+ std::unique_ptr<pending_diagnostic> m_d;
+ const exploded_edge *m_trailing_eedge;
private:
DISABLE_COPY_AND_ASSIGN (saved_diagnostic);
- enum status m_status;
- unsigned m_epath_length;
- feasibility_problem *m_problem;
+ unsigned m_idx;
+ 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;
};
class path_builder;
engine *get_engine () const { return m_eng; }
- void add_diagnostic (const state_machine *sm,
- const exploded_node *enode,
+ json::object *to_json () const;
+
+ 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,
- pending_diagnostic *d);
+ std::unique_ptr<pending_diagnostic> d);
- void add_diagnostic (const exploded_node *enode,
+ bool add_diagnostic (exploded_node *enode,
const supernode *snode, const gimple *stmt,
- stmt_finder *finder,
- pending_diagnostic *d);
+ const stmt_finder *finder,
+ std::unique_ptr<pending_diagnostic> d);
+
+ void add_note (std::unique_ptr<pending_note> pn);
void emit_saved_diagnostics (const exploded_graph &eg);
void emit_saved_diagnostic (const exploded_graph &eg,
- const saved_diagnostic &sd,
- const exploded_path &epath,
- const gimple *stmt,
- int num_dupes);
+ const saved_diagnostic &sd);
unsigned get_num_diagnostics () const
{
const exploded_path &epath,
checker_path *emission_path) const;
+ void add_event_on_final_node (const path_builder &pb,
+ const exploded_node *final_enode,
+ checker_path *emission_path,
+ interesting_t *interest) const;
+
void add_events_for_eedge (const path_builder &pb,
const exploded_edge &eedge,
- checker_path *emission_path) const;
+ checker_path *emission_path,
+ interesting_t *interest) const;
bool significant_edge_p (const path_builder &pb,
const exploded_edge &eedge) const;
state_machine::state_t state) const;
void update_for_unsuitable_sm_exprs (tree *expr) const;
void prune_interproc_events (checker_path *path) const;
+ void consolidate_conditions (checker_path *path) const;
void finish_pruning (checker_path *path) const;
engine *m_eng;
auto_delete_vec<saved_diagnostic> m_saved_diagnostics;
const int m_verbosity;
+ int m_num_disabled_diagnostics;
};
} // namespace ana