6

I'm trying to explore libclang (on Windows) to do "stuff*" based on parsing the AST. I find several examples, I'm unable to get anything to work.

When I try to run this

index = clang.cindex.Index.create()
tu = index.parse(sys.argv[1], args=['-x', 'c++'])
print len(tu.cursor.get_children())

I get an access violation,

File "C:\python27\lib\site-packages\clang\cindex.py", line 1783, in get_children children) WindowsError: exception: access violation writing 0x000000001D1B81A8

The cindex.py is slightly different in here (https://github.com/llvm-mirror/clang/tree/master/bindings/python) but gives the same result, just a different line.

Additionally, it appears there are a few outstanding bugs (https://bugs.llvm.org/show_bug.cgi?id=13907) that sound very similar... although several years old now.

With that, is anyone currently using this on Windows? It appears this may have worked at some point...

It appears libclang is the recommended way of doing this, and python is easy to use, but doesn't appear functional.

*Note: by stuff, I want to generate serialization functions or bindings using attributes to mark up classes/structs.

LLVM 7.0 (and 6.0)
Windows 10
python 2.7 x64

g3cko
  • 920
  • 1
  • 6
  • 21

0 Answers0