# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/core.py
# X86_PATTERNS = ["amd64", "AMD64", "[xX]86", "[xX]86_64", "[iI]386", "[iI]486",
#                 "[iI]686"]
# PPC_PATTERNS = ["PPC", "ppc", "power[pP][cC]", "POWER[pP][cC]"]
# def get_supported_checkers():
# def get_supported_extensions():
# def execute(command):
# def execute_stdout(command):
# def cmdexists(command):
# def get_timestamp():
# def get_files(location, hint=''):
# def get_file_content(file_name, offset, length):
# def get_raw_node(node):
# def get_includes(file_path):
# def get_ifdefs(file_path):
# def get_ifdef_regex(arch, separator):


import re
import os
from clang.cindex import CursorKind
from clang.cindex import TypeKind
from ma.checkers.checker import Checker
from ma import core
    def _get_var_declaration(self, node, definition):
        """ Get where a variable is defined and return the corresponding
        node """
        aux_node = None
        if node.type.kind == TypeKind.TYPEDEF:
            aux_node = node.type.get_declaration()
        elif node.kind == CursorKind.DECL_REF_EXPR:
            aux_node = node.get_definition()

        if aux_node:
            node = aux_node
            definition = node

        for children in node.get_children():
            return self._get_var_declaration(children, definition)

    @staticmethod
    def _has_children(node):
        """ Check if node has children """
        return len(list(node.get_children()))

    @staticmethod
    def _is_dangerous_type(node):
        """ Check if node type can be a dangerous type. For this checker it
        can be dangerous if it is only char (without signed or unsigned) """
        node_type = node.type
        node_type_kind = node_type.kind
        if node_type_kind == TypeKind.TYPEDEF:
            node_type_kind = node_type.get_canonical().kind
        if node_type_kind in (TypeKind.CHAR_U, TypeKind.CHAR_S):

# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/core.py
# X86_PATTERNS = ["amd64", "AMD64", "[xX]86", "[xX]86_64", "[iI]386", "[iI]486",
#                 "[iI]686"]
# PPC_PATTERNS = ["PPC", "ppc", "power[pP][cC]", "POWER[pP][cC]"]
# def get_supported_checkers():
# def get_supported_extensions():
# def execute(command):
# def execute_stdout(command):
# def cmdexists(command):
# def get_timestamp():
# def get_files(location, hint=''):
# def get_file_content(file_name, offset, length):
# def get_raw_node(node):
# def get_includes(file_path):
# def get_ifdefs(file_path):
# def get_ifdef_regex(arch, separator):


# Path: ma/checkers/char_checker.py
import re
import os
from clang.cindex import CursorKind
from clang.cindex import TypeKind
from ma.checkers.checker import Checker
from ma import core

    def _get_var_declaration(self, node, definition):
        """ Get where a variable is defined and return the corresponding
        node """
        aux_node = None
        if node.type.kind == TypeKind.TYPEDEF:
            aux_node = node.type.get_declaration()
        elif node.kind == CursorKind.DECL_REF_EXPR:
            aux_node = node.get_definition()

        if aux_node:
            node = aux_node
            definition = node

        for children in node.get_children():
            return self._get_var_declaration(children, definition)

    @staticmethod
    def _has_children(node):
        """ Check if node has children """
        return len(list(node.get_children()))

    @staticmethod
    def _is_dangerous_type(node):
        """ Check if node type can be a dangerous type. For this checker it
        can be dangerous if it is only char (without signed or unsigned) """
        node_type = node.type
        node_type_kind = node_type.kind
        if node_type_kind == TypeKind.TYPEDEF:
            node_type_kind = node_type.get_canonical().kind
        if node_type_kind in (TypeKind.CHAR_U, TypeKind.CHAR_S):

            return True