class AdLint::Exam::CBuiltin::W0598
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 13952 def initialize(phase_ctxt) super interp = phase_ctxt[:cc1_interpreter] interp.on_sequence_point_reached += T(:commit_changes) interp.on_variable_value_updated += T(:update_variable) @update_cnt = [Hash.new(0)] end
Private Instance Methods
commit_changes(seqp)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13961 def commit_changes(seqp) if seqp.obvious? updated_vars = @update_cnt.map { |hash| hash.keys }.flatten.uniq updated_vars.each do |var| if @update_cnt.count { |hash| hash.include?(var) } > 1 if @update_cnt.map { |hash| hash[var] }.max == 1 W(seqp.location, var.name) end end end @update_cnt = [Hash.new(0)] else @update_cnt.push(Hash.new(0)) end end
update_variable(*, var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13977 def update_variable(*, var) @update_cnt.last[var] += 1 if var.named? end