[llvm-dev] typedef not present in the python AST

Valentin Tolmer via llvm-dev llvm-dev at lists.llvm.org
Sat May 7 21:13:44 PDT 2016


I'm trying to use the python libclang bindings to write a C++
style-checker, and I'd like to detect all the typedefs to recommend
switching to using. I'm using libclang 3.8, with the python bindings
provided with it.

When I parse a file with
index = clang.cindex.Index.create()
tu = index.parse(f, ['-x', 'c++', '-std=c++11', '-fsyntax-only', '-I', '.'])

and then I display the node kinds of every node in the AST
(recursively calling get_children() on every node), I get a node of
type CursorKind.TYPEDEF_DECL, but only if it is top-level (or inside a
namespace or class).

If the typedef is in a function body, it doesn't get reported at all
(even though variable declarations before and after are reported).

Why are they not reported?


Valentin Tolmer

More information about the llvm-dev mailing list