[cfe-dev] Access default template parameters using libclang in python (or C)
Isaiah Norton
isaiah.norton at gmail.com
Sat Feb 22 07:15:23 PST 2014
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
On Sat, Feb 22, 2014 at 6:42 AM, Thomas Weidner
<thomas001le at googlemail.com>wrote:
> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140222/39ff9cb7/attachment.html>
More information about the cfe-dev
mailing list