if (is_named_call_p (callee_fndecl, "fclose", call, 1))
{
tree arg = gimple_call_arg (call, 0);
- tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->on_transition (node, stmt, arg, m_start, m_closed);
if (sm_ctxt->get_state (stmt, arg) == m_closed)
{
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->warn (node, stmt, arg,
new double_fclose (*this, diag_arg));
sm_ctxt->set_next_state (stmt, arg, m_stop);
if (TREE_CODE (op) == MEM_REF)
{
tree arg = TREE_OPERAND (op, 0);
- tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
state_t state = sm_ctxt->get_state (stmt, arg);
if (unchecked_p (state))
{
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->warn (node, stmt, arg,
new possible_null_deref (*this, diag_arg));
const allocation_state *astate = as_a_allocation_state (state);
}
else if (state == m_null)
{
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->warn (node, stmt, arg,
new null_deref (*this, diag_arg));
sm_ctxt->set_next_state (stmt, arg, m_stop);
}
else if (freed_p (state))
{
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
const allocation_state *astate = as_a_allocation_state (state);
sm_ctxt->warn (node, stmt, arg,
new use_after_free (*this, diag_arg,
if (argno >= gimple_call_num_args (call))
return;
tree arg = gimple_call_arg (call, argno);
- tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
state_t state = sm_ctxt->get_state (call, arg);
if (!astate->m_deallocators->contains_p (d))
{
/* Wrong allocator. */
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
pending_diagnostic *pd
= new mismatching_deallocation (*this, diag_arg,
astate->m_deallocators,
else if (state == d->m_freed)
{
/* freed -> stop, with warning. */
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->warn (node, call, arg,
new double_free (*this, diag_arg, d->m_name));
sm_ctxt->set_next_state (call, arg, m_stop);
else if (state == m_non_heap)
{
/* non-heap -> stop, with warning. */
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->warn (node, call, arg,
new free_of_non_heap (*this, diag_arg,
d->m_name));
const gcall *call) const
{
tree ptr = gimple_call_arg (call, 0);
- tree diag_ptr = sm_ctxt->get_diagnostic_tree (ptr);
state_t state = sm_ctxt->get_state (call, ptr);
if (astate->m_deallocators != &m_free)
{
/* Wrong allocator. */
+ tree diag_ptr = sm_ctxt->get_diagnostic_tree (ptr);
pending_diagnostic *pd
= new mismatching_deallocation (*this, diag_ptr,
astate->m_deallocators,
const gimple *stmt,
tree arg) const
{
- tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
if (sm_ctxt->get_state (stmt, arg) == m_sensitive)
- sm_ctxt->warn (node, stmt, arg,
- new exposure_through_output_file (*this, diag_arg));
+ {
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
+ sm_ctxt->warn (node, stmt, arg,
+ new exposure_through_output_file (*this, diag_arg));
+ }
}
/* Implementation of state_machine::on_stmt vfunc for
if (op == ARRAY_REF)
{
tree arg = TREE_OPERAND (rhs1, 1);
- tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
/* Unsigned types have an implicit lower bound. */
bool is_unsigned = false;
if (state == m_tainted)
{
/* Complain about missing bounds. */
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
pending_diagnostic *d
= new tainted_array_index (*this, diag_arg,
is_unsigned
else if (state == m_has_lb)
{
/* Complain about missing upper bound. */
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->warn (node, stmt, arg,
new tainted_array_index (*this, diag_arg,
BOUNDS_LOWER));
/* Complain about missing lower bound. */
if (!is_unsigned)
{
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
sm_ctxt->warn (node, stmt, arg,
new tainted_array_index (*this, diag_arg,
BOUNDS_UPPER));