analyzer: use std::unique_ptr for checker_event
gcc/analyzer/ChangeLog: * call-info.cc: Use std::unique_ptr for checker_event. * checker-path.cc: Likewise. * checker-path.h: Likewise. * diagnostic-manager.cc: Likewise. * engine.cc: Likewise. * pending-diagnostic.cc: Likewise. * sm-signal.cc: Likewise. * varargs.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
parent
e031c5a17a
commit
d60b40b86b
8 changed files with 133 additions and 120 deletions
|
@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "analyzer/diagnostic-manager.h"
|
||||
#include "analyzer/exploded-graph.h"
|
||||
#include "analyzer/call-info.h"
|
||||
#include "make-unique.h"
|
||||
|
||||
#if ENABLE_ANALYZER
|
||||
|
||||
|
@ -113,7 +114,7 @@ call_info::add_events_to_path (checker_path *emission_path,
|
|||
tree caller_fndecl = src_point.get_fndecl ();
|
||||
const int stack_depth = src_point.get_stack_depth ();
|
||||
|
||||
emission_path->add_event (new call_event (get_call_stmt ()->location,
|
||||
emission_path->add_event (make_unique<call_event> (get_call_stmt ()->location,
|
||||
caller_fndecl,
|
||||
stack_depth,
|
||||
this));
|
||||
|
|
|
@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "analyzer/diagnostic-manager.h"
|
||||
#include "analyzer/checker-path.h"
|
||||
#include "analyzer/exploded-graph.h"
|
||||
#include "make-unique.h"
|
||||
|
||||
#if ENABLE_ANALYZER
|
||||
|
||||
|
@ -1262,15 +1263,15 @@ checker_path::add_region_creation_events (const region *reg,
|
|||
if (const svalue *capacity_sval = model->get_capacity (reg))
|
||||
capacity = model->get_representative_tree (capacity_sval);
|
||||
|
||||
add_event (new region_creation_event (reg, capacity, RCE_MEM_SPACE,
|
||||
add_event (make_unique<region_creation_event> (reg, capacity, RCE_MEM_SPACE,
|
||||
loc, fndecl, depth));
|
||||
|
||||
if (capacity)
|
||||
add_event (new region_creation_event (reg, capacity, RCE_CAPACITY,
|
||||
add_event (make_unique<region_creation_event> (reg, capacity, RCE_CAPACITY,
|
||||
loc, fndecl, depth));
|
||||
|
||||
if (debug)
|
||||
add_event (new region_creation_event (reg, capacity, RCE_DEBUG,
|
||||
add_event (make_unique<region_creation_event> (reg, capacity, RCE_DEBUG,
|
||||
loc, fndecl, depth));
|
||||
}
|
||||
|
||||
|
@ -1281,12 +1282,12 @@ checker_path::add_final_event (const state_machine *sm,
|
|||
const exploded_node *enode, const gimple *stmt,
|
||||
tree var, state_machine::state_t state)
|
||||
{
|
||||
checker_event *end_of_path
|
||||
= new warning_event (get_stmt_location (stmt, enode->get_function ()),
|
||||
add_event
|
||||
(make_unique<warning_event> (get_stmt_location (stmt,
|
||||
enode->get_function ()),
|
||||
enode->get_function ()->decl,
|
||||
enode->get_stack_depth (),
|
||||
sm, var, state);
|
||||
add_event (end_of_path);
|
||||
sm, var, state));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -631,9 +631,9 @@ public:
|
|||
|
||||
void maybe_log (logger *logger, const char *desc) const;
|
||||
|
||||
void add_event (checker_event *event)
|
||||
void add_event (std::unique_ptr<checker_event> event)
|
||||
{
|
||||
m_events.safe_push (event);
|
||||
m_events.safe_push (event.release ());
|
||||
}
|
||||
|
||||
void delete_event (int idx)
|
||||
|
|
|
@ -1559,7 +1559,8 @@ public:
|
|||
|
||||
int stack_depth = src_stack_depth;
|
||||
|
||||
m_emission_path->add_event (new state_change_event (supernode,
|
||||
m_emission_path->add_event
|
||||
(make_unique<state_change_event> (supernode,
|
||||
stmt,
|
||||
stack_depth,
|
||||
sm,
|
||||
|
@ -1602,7 +1603,8 @@ public:
|
|||
if (!stmt)
|
||||
return false;
|
||||
|
||||
m_emission_path->add_event (new state_change_event (supernode,
|
||||
m_emission_path->add_event
|
||||
(make_unique<state_change_event> (supernode,
|
||||
stmt,
|
||||
stack_depth,
|
||||
sm,
|
||||
|
@ -1743,7 +1745,8 @@ struct null_assignment_sm_context : public sm_context
|
|||
const supernode *supernode = m_point->get_supernode ();
|
||||
int stack_depth = m_point->get_stack_depth ();
|
||||
|
||||
m_emission_path->add_event (new state_change_event (supernode,
|
||||
m_emission_path->add_event
|
||||
(make_unique<state_change_event> (supernode,
|
||||
m_stmt,
|
||||
stack_depth,
|
||||
m_sm,
|
||||
|
@ -1765,7 +1768,8 @@ struct null_assignment_sm_context : public sm_context
|
|||
const supernode *supernode = m_point->get_supernode ();
|
||||
int stack_depth = m_point->get_stack_depth ();
|
||||
|
||||
m_emission_path->add_event (new state_change_event (supernode,
|
||||
m_emission_path->add_event
|
||||
(make_unique<state_change_event> (supernode,
|
||||
m_stmt,
|
||||
stack_depth,
|
||||
m_sm,
|
||||
|
@ -1907,7 +1911,7 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
|
|||
if (dst_point.get_supernode ()->entry_p ())
|
||||
{
|
||||
emission_path->add_event
|
||||
(new function_entry_event
|
||||
(make_unique<function_entry_event>
|
||||
(dst_point.get_supernode ()->get_start_location (),
|
||||
dst_point.get_fndecl (),
|
||||
dst_stack_depth));
|
||||
|
@ -1943,14 +1947,14 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
|
|||
const gcall *call = dyn_cast <const gcall *> (stmt);
|
||||
if (call && is_setjmp_call_p (call))
|
||||
emission_path->add_event
|
||||
(new setjmp_event (stmt->location,
|
||||
(make_unique<setjmp_event> (stmt->location,
|
||||
dst_node,
|
||||
dst_point.get_fndecl (),
|
||||
dst_stack_depth,
|
||||
call));
|
||||
else
|
||||
emission_path->add_event
|
||||
(new statement_event (stmt,
|
||||
(make_unique<statement_event> (stmt,
|
||||
dst_point.get_fndecl (),
|
||||
dst_stack_depth, dst_state));
|
||||
|
||||
|
@ -2042,7 +2046,8 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
|
|||
"this path would have been rejected as infeasible"
|
||||
" at this edge: ");
|
||||
pb.get_feasibility_problem ()->dump_to_pp (&pp);
|
||||
emission_path->add_event (new precanned_custom_event
|
||||
emission_path->add_event
|
||||
(make_unique<precanned_custom_event>
|
||||
(dst_point.get_location (),
|
||||
dst_point.get_fndecl (),
|
||||
dst_stack_depth,
|
||||
|
@ -2157,14 +2162,15 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb,
|
|||
case SUPEREDGE_CFG_EDGE:
|
||||
{
|
||||
emission_path->add_event
|
||||
(new start_cfg_edge_event (eedge,
|
||||
(make_unique<start_cfg_edge_event> (eedge,
|
||||
(last_stmt
|
||||
? last_stmt->location
|
||||
: UNKNOWN_LOCATION),
|
||||
src_point.get_fndecl (),
|
||||
src_stack_depth));
|
||||
emission_path->add_event
|
||||
(new end_cfg_edge_event (eedge,
|
||||
(make_unique<end_cfg_edge_event>
|
||||
(eedge,
|
||||
dst_point.get_supernode ()->get_start_location (),
|
||||
dst_point.get_fndecl (),
|
||||
dst_stack_depth));
|
||||
|
@ -2180,7 +2186,7 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb,
|
|||
/* TODO: add a subclass for this, or generate events for the
|
||||
summary. */
|
||||
emission_path->add_event
|
||||
(new debug_event ((last_stmt
|
||||
(make_unique<debug_event> ((last_stmt
|
||||
? last_stmt->location
|
||||
: UNKNOWN_LOCATION),
|
||||
src_point.get_fndecl (),
|
||||
|
@ -2196,7 +2202,7 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb,
|
|||
|
||||
const gcall *call_stmt = return_edge->get_call_stmt ();
|
||||
emission_path->add_event
|
||||
(new return_event (eedge,
|
||||
(make_unique<return_event> (eedge,
|
||||
(call_stmt
|
||||
? call_stmt->location
|
||||
: UNKNOWN_LOCATION),
|
||||
|
|
|
@ -1772,7 +1772,8 @@ public:
|
|||
src_point.get_fndecl (),
|
||||
src_stack_depth,
|
||||
"stack frame is popped here, invalidating saved environment");
|
||||
emission_path->add_event (m_stack_pop_event);
|
||||
emission_path->add_event
|
||||
(std::unique_ptr<custom_event> (m_stack_pop_event));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
@ -2015,14 +2016,16 @@ dynamic_call_info_t::add_events_to_path (checker_path *emission_path,
|
|||
const int dest_stack_depth = dest_point.get_stack_depth ();
|
||||
|
||||
if (m_is_returning_call)
|
||||
emission_path->add_event (new return_event (eedge,
|
||||
emission_path->add_event
|
||||
(make_unique<return_event> (eedge,
|
||||
(m_dynamic_call
|
||||
? m_dynamic_call->location
|
||||
: UNKNOWN_LOCATION),
|
||||
dest_point.get_fndecl (),
|
||||
dest_stack_depth));
|
||||
else
|
||||
emission_path->add_event (new call_event (eedge,
|
||||
emission_path->add_event
|
||||
(make_unique<call_event> (eedge,
|
||||
(m_dynamic_call
|
||||
? m_dynamic_call->location
|
||||
: UNKNOWN_LOCATION),
|
||||
|
@ -2072,12 +2075,12 @@ rewind_info_t::add_events_to_path (checker_path *emission_path,
|
|||
const int dst_stack_depth = dst_point.get_stack_depth ();
|
||||
|
||||
emission_path->add_event
|
||||
(new rewind_from_longjmp_event
|
||||
(make_unique<rewind_from_longjmp_event>
|
||||
(&eedge, get_longjmp_call ()->location,
|
||||
src_point.get_fndecl (),
|
||||
src_stack_depth, this));
|
||||
emission_path->add_event
|
||||
(new rewind_to_setjmp_event
|
||||
(make_unique<rewind_to_setjmp_event>
|
||||
(&eedge, get_setjmp_call ()->location,
|
||||
dst_point.get_fndecl (),
|
||||
dst_stack_depth, this));
|
||||
|
@ -2666,7 +2669,7 @@ public:
|
|||
const exploded_edge &) const final override
|
||||
{
|
||||
emission_path->add_event
|
||||
(new tainted_args_function_custom_event
|
||||
(make_unique<tainted_args_function_custom_event>
|
||||
(DECL_SOURCE_LOCATION (m_fndecl), m_fndecl, 0));
|
||||
}
|
||||
|
||||
|
@ -3111,14 +3114,15 @@ public:
|
|||
/* Show the field in the struct declaration, e.g.
|
||||
"(1) field 'store' is marked with '__attribute__((tainted_args))'" */
|
||||
emission_path->add_event
|
||||
(new tainted_args_field_custom_event (m_field));
|
||||
(make_unique<tainted_args_field_custom_event> (m_field));
|
||||
|
||||
/* Show the callback in the initializer
|
||||
e.g.
|
||||
"(2) function 'gadget_dev_desc_UDC_store' used as initializer
|
||||
for field 'store' marked with '__attribute__((tainted_args))'". */
|
||||
emission_path->add_event
|
||||
(new tainted_args_callback_custom_event (m_loc, m_fndecl, 0, m_field));
|
||||
(make_unique<tainted_args_callback_custom_event> (m_loc, m_fndecl,
|
||||
0, m_field));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "analyzer/exploded-graph.h"
|
||||
#include "diagnostic-path.h"
|
||||
#include "analyzer/checker-path.h"
|
||||
#include "make-unique.h"
|
||||
|
||||
#if ENABLE_ANALYZER
|
||||
|
||||
|
@ -178,7 +179,7 @@ pending_diagnostic::add_call_event (const exploded_edge &eedge,
|
|||
const int src_stack_depth = src_point.get_stack_depth ();
|
||||
const gimple *last_stmt = src_point.get_supernode ()->get_last_stmt ();
|
||||
emission_path->add_event
|
||||
(new call_event (eedge,
|
||||
(make_unique<call_event> (eedge,
|
||||
(last_stmt
|
||||
? last_stmt->location
|
||||
: UNKNOWN_LOCATION),
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
const final override
|
||||
{
|
||||
emission_path->add_event
|
||||
(new precanned_custom_event
|
||||
(make_unique<precanned_custom_event>
|
||||
(UNKNOWN_LOCATION, NULL_TREE, 0,
|
||||
"later on,"
|
||||
" when the signal is delivered to the process"));
|
||||
|
|
|
@ -788,7 +788,7 @@ public:
|
|||
= get_num_variadic_arguments (dst_node->get_function ()->decl,
|
||||
call_stmt);
|
||||
emission_path->add_event
|
||||
(new va_arg_call_event (eedge,
|
||||
(make_unique<va_arg_call_event> (eedge,
|
||||
(last_stmt
|
||||
? last_stmt->location
|
||||
: UNKNOWN_LOCATION),
|
||||
|
|
Loading…
Add table
Reference in a new issue