class AdLint::Exam::CBuiltin::W0583
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 13716 def initialize(phase_ctxt) super @interp = phase_ctxt[:cc1_interpreter] @interp.on_function_call_expr_evaled += T(:call_function) @interp.on_explicit_function_defined += T(:check) @funcalls = Hash.new { |hash, key| hash[key] = [] } end
Private Instance Methods
call_function(funcall_expr, fun, arg_vars, *)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13748 def call_function(funcall_expr, fun, arg_vars, *) if fun.named? args = arg_vars.map { |var| [var.type, var.value.to_single_value] } @funcalls[fun.name].push([funcall_expr, args]) end end
check(*, fun)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13725 def check(*, fun) return unless fun.named? return if fun.type.have_va_list? param_types = fun.type.parameter_types.reject { |type| type.void? } @funcalls[fun.name].each do |funcall_expr, args| if args.size == param_types.size types = args.map { |ary| ary.first }.zip(param_types) conformed = types.each_with_index.all? { |(atype, ptype), idx| arg_expr = funcall_expr.argument_expressions[idx] constant_expression?(arg_expr) && untyped_pointer_conversion?(atype, ptype, args[idx].last) or atype.convertible?(ptype) } else conformed = false end W(funcall_expr.location) unless conformed end end
interpreter()
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_check.rb, line 13755 def interpreter @interp end