class AdLint::Exam::CBuiltin::W0771
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 18983 def initialize(phase_ctxt) super interp = phase_ctxt[:cc1_interpreter] interp.on_variable_declared += T(:declare_variable) interp.on_explicit_function_declared += T(:declare_function) interp.on_translation_unit_ended += M(:check) @obj_dcls = Hash.new { |hash, key| hash[key] = [] } end
Private Instance Methods
check(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 19005 def check(*) @obj_dcls.each_value do |dcls| similar_dcls = dcls.uniq { |dcl| dcl.location.fpath } next unless similar_dcls.size > 1 similar_dcls.each do |dcl| W(dcl.location, dcl.identifier.value, *similar_dcls.map { |pair_dcl| next if pair_dcl == dcl C(:C0001, pair_dcl.location, pair_dcl.identifier.value) }.compact) end end end
declare_function(fun_dcl, fun)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 18999 def declare_function(fun_dcl, fun) if fun.named? && fun.declared_as_extern? @obj_dcls[fun.name].push(fun_dcl) end end
declare_variable(var_dcl, var)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 18993 def declare_variable(var_dcl, var) if var.named? && var.declared_as_extern? @obj_dcls[var.name].push(var_dcl) end end