class AdLint::Exam::CBuiltin::W0462

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 9668
def initialize(phase_ctxt)
  super
  @interp = phase_ctxt[:cc1_interpreter]
  @interp.on_function_call_expr_evaled += T(:check)
end

Private Instance Methods

check(funcall_expr, fun, arg_vars, *) click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9675
def check(funcall_expr, fun, arg_vars, *)
  args = arg_vars.zip(fun.type.parameter_types)
  args.each_with_index do |(arg, type), idx|
    next unless arg.variable? && arg.value.scalar?
    next unless type && type.pointer?
    next unless type.unqualify.base_type.const?

    if pointee = pointee_of(arg) and pointee.variable?
      next if pointee.value.test_must_be_undefined.true?
      if !pointee.temporary?
        test = pointee.value.test_may_be_undefined
        if test.true?
          arg_expr = funcall_expr.argument_expressions[idx]
          W(arg_expr.location,
            *test.evidence.emit_context_messages(self, arg_expr.location))
        end
      end
    end
  end
end
interpreter() click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 9696
def interpreter
  @interp
end