<div dir="ltr">Thank you, Mr. Devlieghere!<div><br></div><div><span style="font-size:12.8px">Now, I want to know what other information I can extract from the AST. I have cursorName (or, spelling) and cursorKind spelling. Any other functions that gives me information or just could use to help compare AST nodes. Also, anyway to serialize the AST after generating it or convert it to a format that is reusable afterwards.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Again, the code can be seen on </span><a href="https://github.com/Saurav-K-Aryal/libclang-help" target="_blank" style="font-size:12.8px">https://github.com/Saurav-K-Aryal/libclang-help</a>.</div><div><br></div><div>Sincerely,</div><div>Saurav</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 11, 2016 at 11:48 PM, Jonas Devlieghere <span dir="ltr"><<a href="mailto:jonas@devlieghere.com" target="_blank">jonas@devlieghere.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I can answer some of your questions:<br>
<br>
 - Does libclang get and parse the entire source file? Yes, it will<br>
consider the whole translation unit.<br>
 - Get file location data and skip traversing includes? Use<br>
clang_Location_isFromMainFile(clang_getCursorLocation(cursor))<br>
 - Get the cursor kind as string? Use clang_getCursorKindSpelling(cursor_kind)<br>
<br>
Regards,<br>
<br>
Jonas Devlieghere<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Jul 12, 2016 at 12:13 AM, Aryal, Saurav<br>
<<a href="mailto:saurav.aryal@bison.howard.edu">saurav.aryal@bison.howard.edu</a>> wrote:<br>
> Hi,<br>
><br>
> I have decided to use libclang because I feel like it would suit my purpose<br>
> more. I had run-time concerns with the python bindings but the C bindings<br>
> are working fine.<br>
><br>
> I still have a few more questions/concerns. Please see the README on<br>
> <a href="https://github.com/Saurav-K-Aryal/libclang-help" rel="noreferrer" target="_blank">https://github.com/Saurav-K-Aryal/libclang-help</a> for details.<br>
><br>
> The questions are also listed on the top of the file as comments.<br>
><br>
> Any help would be appreciated.<br>
><br>
> Thanking you.<br>
><br>
> Sincerely,<br>
> Saurav<br>
><br>
> On Mon, Jul 11, 2016 at 1:58 AM, Mikhail Ramalho <<a href="mailto:mikhail.ramalho@gmail.com">mikhail.ramalho@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> If you're interested in libTooling, you can check ESBMC [0], more<br>
>> specifically our clang_c_converter [1].<br>
>><br>
>> We use libTooling to generate the AST and we implement our own AST<br>
>> traverser code. Currently, it only works for C programs; in the future we'll<br>
>> release the C++ code.<br>
>><br>
>> Thanks,<br>
>><br>
>> [0] <a href="https://github.com/esbmc/esbmc" rel="noreferrer" target="_blank">https://github.com/esbmc/esbmc</a><br>
>> [1]<br>
>> <a href="https://github.com/esbmc/esbmc/blob/master/clang-c-frontend/clang_c_convert.cpp" rel="noreferrer" target="_blank">https://github.com/esbmc/esbmc/blob/master/clang-c-frontend/clang_c_convert.cpp</a><br>
>><br>
>><br>
>> 2016-07-08 20:57 GMT+01:00 Jonas Devlieghere via cfe-dev<br>
>> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>>:<br>
>>><br>
>>> On Fri, Jul 8, 2016 at 8:45 PM, Aryal, Saurav via cfe-dev<br>
>>> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
>>> > Hi everyone,<br>
>>> ><br>
>>> > I am just starting out with Clang and working for a project where I am<br>
>>> > trying to generate and compare ASTs to measure code similarity.<br>
>>><br>
>>> Welcome, good luck with your project!<br>
>>><br>
>>> > I figured around a way using Clang to get the AST, but it turns out I<br>
>>> > am<br>
>>> > expected to use Libtooling.<br>
>>><br>
>>> There are actually different interfaces available to interact with<br>
>>> Clang's AST. Which one is best depends on your use case. I'd recommend<br>
>>> looking at [1] to make an informed decision.<br>
>>><br>
>>> > Anyone have an example where I can parse C++<br>
>>> > code to generate an AST using Libtooling.<br>
>>><br>
>>> Yes; clang's documentation [2] contains an excellent tutorial. There<br>
>>> are also many blog post available that will get you started with<br>
>>> concrete examples, including one I wrote myself when I started looking<br>
>>> at the clang AST [3].<br>
>>><br>
>>> > Also, would love design<br>
>>> > suggestions regarding comparing tree similarity. any examples with<br>
>>> > explanations would be really helpful.<br>
>>> ><br>
>>> > Thanking you.<br>
>>> ><br>
>>> > Sincerely,<br>
>>> > Saurav<br>
>>> ><br>
>>> > _______________________________________________<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/mailman/listinfo/cfe-dev</a><br>
>>> ><br>
>>><br>
>>> [1] <a href="http://clang.llvm.org/docs/Tooling.html" rel="noreferrer" target="_blank">http://clang.llvm.org/docs/Tooling.html</a><br>
>>> [2] <a href="http://clang.llvm.org/docs/LibTooling.html" rel="noreferrer" target="_blank">http://clang.llvm.org/docs/LibTooling.html</a><br>
>>> [3] <a href="https://jonasdevlieghere.com/understanding-the-clang-ast/" rel="noreferrer" target="_blank">https://jonasdevlieghere.com/understanding-the-clang-ast/</a>)<br>
>>><br>
>>> -- Jonas<br>
>>> _______________________________________________<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/mailman/listinfo/cfe-dev</a><br>
>><br>
>><br>
>><br>
>><br>
>> --<br>
>><br>
>> Mikhail Ramalho.<br>
><br>
><br>
</div></div></blockquote></div><br></div>