aggregate(0),
r_assignment(0),
assignment_target(false),
- r_assign_to_subscript(false),
+ r_assign_to_subfield(false),
r_side_effects(false)
{ }
void UnusedVariableRemover::visit(MemberAccess &memacc)
{
+ r_assign_to_subfield = true;
TraversingVisitor::visit(memacc);
unused_nodes.erase(memacc.declaration);
}
if(binary.oper->token[0]=='[')
{
if(assignment_target)
- r_assign_to_subscript = true;
+ r_assign_to_subfield = true;
binary.left->visit(*this);
SetForScope<bool> set(assignment_target, false);
binary.right->visit(*this);
void UnusedVariableRemover::visit(Assignment &assign)
{
{
- r_assign_to_subscript = false;
SetForScope<bool> set(assignment_target, !assign.self_referencing);
assign.left->visit(*this);
}
void UnusedVariableRemover::visit(ExpressionStatement &expr)
{
r_assignment = 0;
+ r_assign_to_subfield = false;
r_side_effects = false;
TraversingVisitor::visit(expr);
if(r_assignment && r_assignment->target_declaration)
- record_assignment(*r_assignment->target_declaration, expr, (r_assignment->self_referencing || r_assign_to_subscript));
+ record_assignment(*r_assignment->target_declaration, expr, (r_assignment->self_referencing || r_assign_to_subfield));
if(!r_side_effects)
unused_nodes.insert(&expr);
}