[cfe-dev] libclang-python: recovering from parsing error

Ethan Smith via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 9 17:42:53 PDT 2016

 I was hoping to use libclang to parse files to write a generator. As a
test, I was using libui (https://github.com/andlabs/libui/), however, as I
ran index.parse, all I get is a clang.cindex.TranslationUnitLoadError,
which I can catch, but I cannot seem to find a way to deal with figuring
out _why_ it fails. I noticed in cindex.py:

# o API support for invalid translation units. Currently we can't even get
#   diagnostics on failure because they refer to locations in an object that
#   will have been invalidated.

So it appears I cannot get the diagnostic info? If not, would I be able to
get diagnostics if I use the underlying clang_parseTranslationUnit in C? I
don't mind wrapping some C code if needed.

Thanks for any guidance you can provide!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160809/8ce9ed00/attachment.html>

More information about the cfe-dev mailing list