class AdLint::Exam::CBuiltin::W0088

Public Class Methods

new(phase_ctxt) click to toggle source
Calls superclass method AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 2044
def initialize(phase_ctxt)
  super
  interp = phase_ctxt[:cc1_interpreter]
  interp.on_expression_stmt_started += T(:enter_expression_statement)
  interp.on_expression_stmt_ended   += T(:leave_expression_statement)
  interp.on_logical_and_expr_evaled += T(:check)
  interp.on_logical_or_expr_evaled  += T(:check)
  @cur_expr_stmt = nil
end

Private Instance Methods

check(expr, *) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 2069
def check(expr, *)
  if @cur_expr_stmt
    unless expr.rhs_operand.have_side_effect?
      W(expr.operator.location)
    end
  end
end
enter_expression_statement(expr_stmt) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 2055
def enter_expression_statement(expr_stmt)
  case expr_stmt.expression
  when Cc1::SimpleAssignmentExpression, Cc1::CompoundAssignmentExpression,
       Cc1::FunctionCallExpression
    @cur_expr_stmt = nil
  else
    @cur_expr_stmt = expr_stmt
  end
end
leave_expression_statement(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 2065
def leave_expression_statement(*)
  @cur_expr_stmt = nil
end