<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div><br></div><div><br>On 13 Aug 2016, at 22:33, Ethan Smith via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div><div>Thanks for your reply vedant,<br><br></div>I think I might work on a patch. It seems if I use clang_<wbr>createTranslationUnitFromSourc<wbr>eFile, I can pass the return as the TranslationUnit parameter for clang_parseTranslationUnit2. After a bit of fiddling, I found that I needed to make my own enum wrapper for CXErrorCode (where should I place the code for this? In cindex near the <span>"Exception Classes" section?), and now I can get the correct return code. <br><br>I was thinking of giving the CXErrorCode in the TranslationUnitLoadError given. (Eg,  "clang.cindex.TranslationUnitLoadError: Error parsing translation unit: </span><span>
CXError_InvalidArguments") <br><br>Also, since this moves to clang_parseTranslationUnit2, and there are no other references to the it, should I comment out clang_parseTranslationUnit? Or leave it in?<br><br></span></div><span>Also, I should submit this fix once I hear back on the above as a Github PR, correct?<br><br></span></div></div></div></blockquote><div><br></div><div>I think that GitHub is just a mirror of an SVN repository. I've submitted any patches to LLVM/Clang on Phabricator </div><div><br></div><div><a href="http://llvm.org/docs/Phabricator.html">http://llvm.org/docs/Phabricator.html</a></div><div><br></div><div>If you look at recent changes to the clang bindings in the history then you can find people who might be able to review your (very welcome) changes.</div><div><br></div><div>Regards</div><div><br></div><div>Jon</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><span>~>Ethan<br></span></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 12, 2016 at 6:45 PM, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Ethan,<br>
<br>
Unfortunately, this is a known bug in the python bindings (see: the FIXME in<br>
bindings/clang/cindex.py). The fix here should be to 1) expose a function which<br>
can unwrap a CXErrorCode into a more pythonic error value and 2) use that<br>
function to help move from the clang_parseTranslationUnit API to<br>
clang_parseTranslationUnit2.<br>
<br>
If you don't have the time to put together a patch, you might be able to get a<br>
debugger to break on clang_parseTranslationUnit and inspect the error state<br>
there.<br>
<br>
best,<br>
vedant<br>
<div><div class="h5"><br>
> On Aug 8, 2016, at 10:36 AM, Ethan Smith via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> First off, thanks for the awesome library!<br>
><br>
> I am using the Python bindings of libclang. I am trying to use it to parse really any c/c++ library for code generation, however, as an example, I tried to bind libui (<a href="https://github.com/andlabs/libui" rel="noreferrer" target="_blank">https://github.com/andlabs/<wbr>libui</a>). However, when I try to index.parse after setting up a clang index, I get a TranslationUnitLoadError. Since this returns a null pointer, I can't figure out what went wrong. Is there a way to tell what is causing the parser to fail? I also tried to pass 0x200 ( CXTranslationUnit_KeepGoing) as an option, which should, as I understand it, tell the parser to continue on fail, it has no effect. How can I get some useful information to tell me what I need to do to fix the parser error? For the record, the library compiles fine with clang itself.<br>
><br>
> Could I expose more useful info from the c libclang? I suppose I'm not opposed to writing my own bindings.<br>
><br>
> Thanks!<br>
><br>
> Ethan<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>cfe-dev mailing list</span><br><span><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a></span><br><span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></span><br></div></blockquote></body></html>