class AdLint::Exam::CBuiltin::W0629

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 14799
def initialize(phase_ctxt)
  super
  interp = phase_ctxt[:cc1_interpreter]
  interp.on_explicit_function_defined += T(:define_function)
  interp.on_function_referred         += T(:refer_function)
  interp.on_translation_unit_ended    += M(:check)
  @static_functions = {}
end

Private Instance Methods

check(*) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 14809
def check(*)
  @static_functions.map { |name, (cnt, loc)|
    cnt == 0 ? [name, loc] : nil
  }.compact.each { |name, loc| W(loc, name) }
end
define_function(fun_def, fun) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 14815
def define_function(fun_def, fun)
  if fun.declared_as_static?
    @static_functions[fun.name] ||= [0, fun_def.location]
    @static_functions[fun.name][1] ||= fun_def.location
  end
end
refer_function(*, fun) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 14822
def refer_function(*, fun)
  if fun.named?
    if rec = @static_functions[fun.name]
      rec[0] += 1
    else
      @static_functions[fun.name] = [1, nil]
    end
  end
end