class AdLint::Exam::CBuiltin::W0477
Public Class Methods
new(phase_ctxt)
click to toggle source
Calls superclass method
AdLint::Examination::new
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 619 def initialize(phase_ctxt) super interp = phase_ctxt[:cpp_interpreter] interp.on_object_like_macro_defined += T(:check) interp.on_function_like_macro_defined += T(:check) interp.on_va_function_like_macro_defined += T(:check) end
Private Instance Methods
check(define_line, macro)
click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 628 def check(define_line, macro) if repl_list = macro.replacement_list paren_count = 0 brace_count = 0 bracket_count = 0 repl_list.tokens.each do |pp_tok| case pp_tok.value when "(" paren_count += 1 when ")" paren_count -= 1 when "{" brace_count += 1 when "}" brace_count -= 1 when "[" bracket_count += 1 when "]" bracket_count -= 1 end end unless paren_count == 0 && brace_count == 0 && bracket_count == 0 W(define_line.location) end end end