#include "analyzer/diagnostic-manager.h"
#include "analyzer/exploded-graph.h"
#include "analyzer/call-info.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
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,
- caller_fndecl,
- stack_depth,
- this));
+ emission_path->add_event (make_unique<call_event> (get_call_stmt ()->location,
+ caller_fndecl,
+ stack_depth,
+ this));
}
/* Recreate a call_details instance from this call_info. */
#include "analyzer/diagnostic-manager.h"
#include "analyzer/checker-path.h"
#include "analyzer/exploded-graph.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
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,
- loc, fndecl, depth));
+ 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,
- loc, fndecl, depth));
+ 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,
- loc, fndecl, depth));
+ add_event (make_unique<region_creation_event> (reg, capacity, RCE_DEBUG,
+ loc, fndecl, depth));
}
/* Add a warning_event to the end of this path. */
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 ()),
- enode->get_function ()->decl,
- enode->get_stack_depth (),
- sm, var, state);
- add_event (end_of_path);
+ add_event
+ (make_unique<warning_event> (get_stmt_location (stmt,
+ enode->get_function ()),
+ enode->get_function ()->decl,
+ enode->get_stack_depth (),
+ sm, var, state));
}
void
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)
int stack_depth = src_stack_depth;
- m_emission_path->add_event (new state_change_event (supernode,
- stmt,
- stack_depth,
- sm,
- NULL,
- src_sm_val,
- dst_sm_val,
- NULL,
- dst_state));
+ m_emission_path->add_event
+ (make_unique<state_change_event> (supernode,
+ stmt,
+ stack_depth,
+ sm,
+ NULL,
+ src_sm_val,
+ dst_sm_val,
+ NULL,
+ dst_state));
return false;
}
if (!stmt)
return false;
- m_emission_path->add_event (new state_change_event (supernode,
- stmt,
- stack_depth,
- sm,
- sval,
- src_sm_val,
- dst_sm_val,
- dst_origin_sval,
- dst_state));
+ m_emission_path->add_event
+ (make_unique<state_change_event> (supernode,
+ stmt,
+ stack_depth,
+ sm,
+ sval,
+ src_sm_val,
+ dst_sm_val,
+ dst_origin_sval,
+ dst_state));
return false;
}
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_stmt,
- stack_depth,
- m_sm,
- var_new_sval,
- from, to,
- NULL,
- *m_new_state));
+ m_emission_path->add_event
+ (make_unique<state_change_event> (supernode,
+ m_stmt,
+ stack_depth,
+ m_sm,
+ var_new_sval,
+ from, to,
+ NULL,
+ *m_new_state));
}
void set_next_state (const gimple *stmt,
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_stmt,
- stack_depth,
- m_sm,
- sval,
- from, to,
- NULL,
- *m_new_state));
+ m_emission_path->add_event
+ (make_unique<state_change_event> (supernode,
+ m_stmt,
+ stack_depth,
+ m_sm,
+ sval,
+ from, to,
+ NULL,
+ *m_new_state));
}
void warn (const supernode *, const gimple *,
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));
const gcall *call = dyn_cast <const gcall *> (stmt);
if (call && is_setjmp_call_p (call))
emission_path->add_event
- (new setjmp_event (stmt->location,
- dst_node,
- dst_point.get_fndecl (),
- dst_stack_depth,
- call));
+ (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,
- dst_point.get_fndecl (),
- dst_stack_depth, dst_state));
+ (make_unique<statement_event> (stmt,
+ dst_point.get_fndecl (),
+ dst_stack_depth, dst_state));
/* Create state change events for assignment to NULL.
Iterate through the stmts in dst_enode, adding state change
"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
- (dst_point.get_location (),
- dst_point.get_fndecl (),
- dst_stack_depth,
- pp_formatted_text (&pp)));
+ emission_path->add_event
+ (make_unique<precanned_custom_event>
+ (dst_point.get_location (),
+ dst_point.get_fndecl (),
+ dst_stack_depth,
+ pp_formatted_text (&pp)));
}
}
case SUPEREDGE_CFG_EDGE:
{
emission_path->add_event
- (new start_cfg_edge_event (eedge,
- (last_stmt
- ? last_stmt->location
- : UNKNOWN_LOCATION),
- src_point.get_fndecl (),
- src_stack_depth));
+ (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,
- dst_point.get_supernode ()->get_start_location (),
- dst_point.get_fndecl (),
- dst_stack_depth));
+ (make_unique<end_cfg_edge_event>
+ (eedge,
+ dst_point.get_supernode ()->get_start_location (),
+ dst_point.get_fndecl (),
+ dst_stack_depth));
}
break;
/* TODO: add a subclass for this, or generate events for the
summary. */
emission_path->add_event
- (new debug_event ((last_stmt
- ? last_stmt->location
- : UNKNOWN_LOCATION),
- src_point.get_fndecl (),
- src_stack_depth,
- "call summary"));
+ (make_unique<debug_event> ((last_stmt
+ ? last_stmt->location
+ : UNKNOWN_LOCATION),
+ src_point.get_fndecl (),
+ src_stack_depth,
+ "call summary"));
}
break;
const gcall *call_stmt = return_edge->get_call_stmt ();
emission_path->add_event
- (new return_event (eedge,
- (call_stmt
- ? call_stmt->location
- : UNKNOWN_LOCATION),
- dst_point.get_fndecl (),
- dst_stack_depth));
+ (make_unique<return_event> (eedge,
+ (call_stmt
+ ? call_stmt->location
+ : UNKNOWN_LOCATION),
+ dst_point.get_fndecl (),
+ dst_stack_depth));
}
break;
}
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;
const int dest_stack_depth = dest_point.get_stack_depth ();
if (m_is_returning_call)
- emission_path->add_event (new return_event (eedge,
- (m_dynamic_call
- ? m_dynamic_call->location
- : UNKNOWN_LOCATION),
- dest_point.get_fndecl (),
- dest_stack_depth));
+ 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,
- (m_dynamic_call
- ? m_dynamic_call->location
- : UNKNOWN_LOCATION),
- src_point.get_fndecl (),
- src_stack_depth));
+ emission_path->add_event
+ (make_unique<call_event> (eedge,
+ (m_dynamic_call
+ ? m_dynamic_call->location
+ : UNKNOWN_LOCATION),
+ src_point.get_fndecl (),
+ src_stack_depth));
}
/* class rewind_info_t : public custom_edge_info. */
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));
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));
}
/* 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:
#include "analyzer/exploded-graph.h"
#include "diagnostic-path.h"
#include "analyzer/checker-path.h"
+#include "make-unique.h"
#if ENABLE_ANALYZER
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,
- (last_stmt
- ? last_stmt->location
- : UNKNOWN_LOCATION),
- src_point.get_fndecl (),
- src_stack_depth));
+ (make_unique<call_event> (eedge,
+ (last_stmt
+ ? last_stmt->location
+ : UNKNOWN_LOCATION),
+ src_point.get_fndecl (),
+ src_stack_depth));
}
} // namespace ana
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"));
= get_num_variadic_arguments (dst_node->get_function ()->decl,
call_stmt);
emission_path->add_event
- (new va_arg_call_event (eedge,
- (last_stmt
- ? last_stmt->location
- : UNKNOWN_LOCATION),
- src_point.get_fndecl (),
- src_stack_depth,
- num_variadic_arguments));
+ (make_unique<va_arg_call_event> (eedge,
+ (last_stmt
+ ? last_stmt->location
+ : UNKNOWN_LOCATION),
+ src_point.get_fndecl (),
+ src_stack_depth,
+ num_variadic_arguments));
}
else
pending_diagnostic::add_call_event (eedge, emission_path);