class AdLint::Exam::CBuiltin::W0791

Public Class Methods

new(phase_ctxt) click to toggle source
Calls superclass method AdLint::Examination::new
# File lib/adlint/exam/c_builtin/ld_check.rb, line 235
def initialize(phase_ctxt)
  super
  phase_ctxt[:ld_function_traversal].on_definition += T(:check_function)
  phase_ctxt[:ld_variable_traversal].on_definition += T(:check_variable)
  @fun_map = phase_ctxt[:ld_function_map]
  @var_map = phase_ctxt[:ld_variable_map]
end

Private Instance Methods

check_function(fun) click to toggle source
# File lib/adlint/exam/c_builtin/ld_check.rb, line 244
def check_function(fun)
  if fun.extern?
    similar_funs = @fun_map.lookup_functions(fun.name)
    if similar_funs.size > 1
      W(fun.location, fun.signature, *similar_funs.map { |pair|
        C(:C0001, pair.location, pair.signature) unless pair == fun
      }.compact)
    end
  end
end
check_variable(var) click to toggle source
# File lib/adlint/exam/c_builtin/ld_check.rb, line 255
def check_variable(var)
  if var.extern?
    similar_vars = @var_map.lookup_variables(var.name)
    if similar_vars.size > 1
      W(var.location, var.name, *similar_vars.map { |pair|
        C(:C0001, pair.location, pair.name) unless pair == var
      }.compact)
    end
  end
end