class AdLint::Exam::CBuiltin::W0443

Constants

KEYWORDS

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 497
def initialize(phase_ctxt)
  super
  trav = phase_ctxt[:cpp_ast_traversal]
  trav.enter_function_like_define_line    += T(:check)
  trav.enter_va_function_like_define_line += T(:check)
end

Private Instance Methods

check(node) click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 505
def check(node)
  return unless node.identifier_list

  if repl_lsit = node.replacement_list
    should_be_function = repl_lsit.tokens.all? { |pp_tok|
      if keyword_or_punctuator?(pp_tok)
        false
      elsif type_specifier_or_type_qualifier?(pp_tok)
        false
      else
        true
      end
    }
    W(node.location) if should_be_function
  end
end
keyword_or_punctuator?(pp_tok) click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 532
def keyword_or_punctuator?(pp_tok)
  pp_tok.value == "#" || pp_tok.value == "##" ||
    pp_tok.value == "{" || pp_tok.value == "}" ||
    pp_tok.value == ";" || KEYWORDS.include?(pp_tok.value)
end
type_specifier_or_type_qualifier?(pp_tok) click to toggle source
# File lib/adlint/exam/c_builtin/cpp_check.rb, line 538
def type_specifier_or_type_qualifier?(pp_tok)
  pp_tok.value == "const" || pp_tok.value == "volatile" ||
    pp_tok.value == "restrict" ||
    @phase_ctxt[:cc1_type_table].all_type_names.include?(pp_tok.value)
end