Ejemplo n.º 1
0
__author__ = "fripSide"

import os
import sys
from config import CONFIG
import clang.cindex
from clang.cindex import *
"""
Build callgraph for given h/c


https://github.com/bluhm/lockfish
"""

TEST_FILE = CONFIG.local_path("data/test/test.cpp")
TEST_JNI_FILE = CONFIG.aosp_file(r"frameworks\base\core\jni\android_util_Binder.cpp")


def find_typerefs(node, typename):
    """ Find all references to the type named 'typename'
    """
    if node.kind.is_reference():
        ref_node = node.get_definition()
        if ref_node.spelling == typename:
            print('Found %s [line=%s, col=%s]' % (
                typename, node.location.line, node.location.column))
    # Recurse for children of this node
    for c in node.get_children():
        find_typerefs(c, typename)