class AdLint::Exam::CBuiltin::FN_RETN
Public Class Methods
new(phase_ctxt)
click to toggle source
Calls superclass method
AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 434 def initialize(phase_ctxt) super @fpath = phase_ctxt[:sources].first.fpath trav = phase_ctxt[:cc1_ast_traversal] trav.enter_ansi_function_definition += T(:enter_function) trav.leave_ansi_function_definition += T(:leave_function) trav.enter_kandr_function_definition += T(:enter_function) trav.leave_kandr_function_definition += T(:leave_function) trav.enter_error_statement += T(:enter_statement) trav.enter_generic_labeled_statement += T(:enter_statement) trav.enter_case_labeled_statement += T(:enter_statement) trav.enter_default_labeled_statement += T(:enter_statement) trav.enter_expression_statement += T(:enter_statement) trav.enter_if_statement += T(:enter_statement) trav.enter_if_else_statement += T(:enter_statement) trav.enter_switch_statement += T(:enter_statement) trav.enter_while_statement += T(:enter_statement) trav.enter_do_statement += T(:enter_statement) trav.enter_for_statement += T(:enter_statement) trav.enter_c99_for_statement += T(:enter_statement) trav.enter_goto_statement += T(:enter_statement) trav.enter_continue_statement += T(:enter_statement) trav.enter_break_statement += T(:enter_statement) trav.enter_return_statement += T(:count_return) @cur_fun = nil @ret_cnt = 0 @lst_stmt = nil end
Private Instance Methods
count_return(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 497 def count_return(node) if @cur_fun @ret_cnt += 1 @lst_stmt = node end end
do_execute(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 465 def do_execute(*) end
do_prepare(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 464 def do_prepare(*) end
enter_function(fun_def)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 467 def enter_function(fun_def) @cur_fun = fun_def @ret_cnt = 0 @lst_stmt = nil end
enter_statement(node)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 491 def enter_statement(node) if @cur_fun @lst_stmt = node if node.executed? end end
leave_function(*)
click to toggle source
# File lib/adlint/exam/c_builtin/cc1_metric.rb, line 473 def leave_function(*) if @cur_fun if @cur_fun.type.return_type.void? && !(@lst_stmt.kind_of?(Cc1::ReturnStatement)) FN_RETN(FunctionId.new(@cur_fun.identifier.value, @cur_fun.signature.to_s), @cur_fun.location, @ret_cnt + 1) else FN_RETN(FunctionId.new(@cur_fun.identifier.value, @cur_fun.signature.to_s), @cur_fun.location, @ret_cnt) end @cur_fun = nil @ret_cnt = 0 @lst_stmt = nil end end