Access default template parameters using libclang in python (or C)

Hello,

I am trying to do some C++ introspection using the AST generated by
libclang. I use the python bindings, but they seem to be a pretty
straightforward mapping to the C API.

There seems to be no way to access the default argument to template
parameters, like

template<class S, class T = bar<S> > struct foo {};

No AST node is generated for bar<S> and there is no method for access
the default argument. Using clangs internal API this is possible.

Is there any way to use libclang for this?

Thanks,
Thomas

The thread linked below says it is necessary to use the tokenizer to get the value for default function arguments.
A similar solution may work for template args.

http://clang-developers.42468.n3.nabble.com/Finding-default-value-for-function-argument-with-clang-c-API-td4036919.html

Here is an approach to find function arguments using the Julia libclang bindings - I think the Python tokenizer API is similar:

https://github.com/ihnorton/Clang.jl/issues/63#issuecomment-35749378

And, just in case you haven’t seen it, there is a fantastic blog post about Python+libclang and C++:

http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/

Isaiah