class AdLint::Exam::CBuiltin::W0736
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 17875 def initialize(phase_ctxt) super interp = phase_ctxt[:cc1_interpreter] interp.on_variable_defined += T(:define_variable) interp.on_variable_referred += T(:refer_variable) interp.on_function_started += T(:enter_function) interp.on_function_ended += T(:leave_function) interp.on_translation_unit_ended += M(:check) @static_vars = {} @functions = [] end
Private Instance Methods
check(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17906 def check(*) @static_vars.each do |var, (var_def, accessors)| W(var_def.location, var.name) if accessors.size == 1 end end
define_variable(var_def, var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17888 def define_variable(var_def, var) return unless @functions.empty? @static_vars[var] = [var_def, Set.new] if var.declared_as_static? end
enter_function(*, fun)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17898 def enter_function(*, fun) @functions.push(fun) end
leave_function(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17902 def leave_function(*) @functions.pop end
refer_variable(*, var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 17893 def refer_variable(*, var) return if @functions.empty? @static_vars[var].last.add(@functions.last) if @static_vars.include?(var) end