class AdLint::Exam::CBuiltin::W0589
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 77 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) @xref_graph = phase_ctxt[:ld_xref_graph] end
Private Instance Methods
check_function(fun)
click to toggle source
# File lib/adlint/exam/c_builtin/ld_check.rb, line 85 def check_function(fun) if fun.extern? refs = @xref_graph.direct_referrers_of(fun) ref_funs = refs.map { |ref| ref.function }.compact.uniq if ref_funs.size == 1 if ref_funs.first.location.fpath == fun.location.fpath W(fun.location, fun.signature, ref_funs.first.signature) end end end end
check_variable(var)
click to toggle source
# File lib/adlint/exam/c_builtin/ld_check.rb, line 97 def check_variable(var) if var.extern? refs = @xref_graph.direct_referrers_of(var) ref_funs = refs.map { |ref| ref.function }.compact.uniq if ref_funs.size == 1 if ref_funs.first.location.fpath == var.location.fpath W(var.location, var.name, ref_funs.first.signature) end end end end