[cfe-dev] [libclang] Is there any method like get_children (python cindex) available for libclang or alternative to print the tree structure by the traversal method?

Carlos Andrade carlosviansi at gmail.com
Sun Jun 17 00:24:54 PDT 2012

I managed to create a transversal using libclang on C, map it to code and
get its types but now I am stuck trying to output it like a tree like it is
done at [1]. For some unknown reason [1] crashes here with the warning
"Python quit unexpectedly while using libclang.dylib plug-in. (Running on
an OS Lion).

On my C version I can get each node being printed, but what I wanted is
what [1] does: Print the structure of the tree (who is child of who) and I
was trying to do so by tying to verify if the child is NULL but I cant find
any method available to do so. [2] Seems to suggest this doesnt even exist
on libclang C.

Is there any work around this? My solely goal is just to print the tree so
if there is a way to do so by not using the null child that would be
welcomed too.

As a side note, I would appreciate if anyone would have come across any
solution to only print what is available on code on libclang and would be
gentle enough to provide the code or few suggestions of functions of
libclang that I could use to do so.

[1] https://gist.github.com/2503232
[2] http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/

Thank you.

Carlos Andrade
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120617/d4e90bb6/attachment.html>

More information about the cfe-dev mailing list