diff options
author | dim <dim@FreeBSD.org> | 2010-10-11 17:22:16 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2010-10-11 17:22:16 +0000 |
commit | 1fc65a65fe54635d0e564559ba5a7b8a8a42d4d6 (patch) | |
tree | de75a464c5dac7eceb2dbbad8b4d4e1479d79e08 /contrib/llvm/tools/clang/bindings/python/examples/cindex/cindex-dump.py | |
parent | f4f7191cd223adebacee3fad260ed60935be9cb9 (diff) | |
download | FreeBSD-src-1fc65a65fe54635d0e564559ba5a7b8a8a42d4d6.zip FreeBSD-src-1fc65a65fe54635d0e564559ba5a7b8a8a42d4d6.tar.gz |
Remove more unneeded files and directories from contrib/llvm. This
still allows us to build tblgen and clang, and further reduces the
footprint in the tree.
Approved by: rpaulo (mentor)
Diffstat (limited to 'contrib/llvm/tools/clang/bindings/python/examples/cindex/cindex-dump.py')
-rw-r--r-- | contrib/llvm/tools/clang/bindings/python/examples/cindex/cindex-dump.py | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/contrib/llvm/tools/clang/bindings/python/examples/cindex/cindex-dump.py b/contrib/llvm/tools/clang/bindings/python/examples/cindex/cindex-dump.py deleted file mode 100644 index af7ddab..0000000 --- a/contrib/llvm/tools/clang/bindings/python/examples/cindex/cindex-dump.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python - -#===- cindex-dump.py - cindex/Python Source Dump -------------*- python -*--===# -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -#===------------------------------------------------------------------------===# - -""" -A simple command line tool for dumping a source file using the Clang Index -Library. -""" - -def get_diag_info(diag): - return { 'severity' : diag.severity, - 'location' : diag.location, - 'spelling' : diag.spelling, - 'ranges' : diag.ranges, - 'fixits' : diag.fixits } - -def get_cursor_id(cursor, cursor_list = []): - if not opts.showIDs: - return None - - if cursor is None: - return None - - # FIXME: This is really slow. It would be nice if the index API exposed - # something that let us hash cursors. - for i,c in enumerate(cursor_list): - if cursor == c: - return i - cursor_list.append(cursor) - return len(cursor_list) - 1 - -def get_info(node, depth=0): - if opts.maxDepth is not None and depth >= opts.maxDepth: - children = None - else: - children = [get_info(c, depth+1) - for c in node.get_children()] - return { 'id' : get_cursor_id(node), - 'kind' : node.kind, - 'usr' : node.get_usr(), - 'spelling' : node.spelling, - 'location' : node.location, - 'extent.start' : node.extent.start, - 'extent.end' : node.extent.end, - 'is_definition' : node.is_definition(), - 'definition id' : get_cursor_id(node.get_definition()), - 'children' : children } - -def main(): - from clang.cindex import Index - from pprint import pprint - - from optparse import OptionParser, OptionGroup - - global opts - - parser = OptionParser("usage: %prog [options] {filename} [clang-args*]") - parser.add_option("", "--show-ids", dest="showIDs", - help="Don't compute cursor IDs (very slow)", - default=False) - parser.add_option("", "--max-depth", dest="maxDepth", - help="Limit cursor expansion to depth N", - metavar="N", type=int, default=None) - parser.disable_interspersed_args() - (opts, args) = parser.parse_args() - - if len(args) == 0: - parser.error('invalid number arguments') - - index = Index.create() - tu = index.parse(None, args) - if not tu: - parser.error("unable to load input") - - pprint(('diags', map(get_diag_info, tu.diagnostics))) - pprint(('nodes', get_info(tu.cursor))) - -if __name__ == '__main__': - main() - |