I have been trying to learn about the AST using python bindings of libclang. But I have not been able to enumerate the fields of a struct successfully. I don’t know if I’m doing it wrong, or if it’s a bug.
Here is the code I wrote: https://gist.github.com/jeet-parekh/936b932b4f2501debd0c40172f6af128
It simply prints the displayname, spelling, and number of fields of a struct.
And I am running it on the imgui.h file from the https://github.com/ocornut/imgui project.
For a lot of the structs, I get “fields count: 0”. I wrote an equivalent program in C++. And I got the same result. How do I fix it?
I have cloned the clang repo from the provided git mirror. The latest commit in my clone is:
git commit id: 3b778bc3cec73f904457d70d6f956e1aafe1b550
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345691 91177308-0d34-0410-b5e6-96231b3b80d8