[cfe-dev] Exporting Clang AST

Mathieu Baudet via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 28 10:50:35 PDT 2015


Hi Bhargava,

You may (or may not) be interested in the JsonASTExporter plugin in
https://github.com/facebook/facebook-clang-plugins .

Pros:
* Exports most of the clang AST in Json (or an equivalent binary format
called "Biniou").
* The Json follows a schema understood by the Ocaml library "atdgen" (
https://mjambon.github.io/atdgen-doc/tutorial).
* Used by the Infer tool (http://fbinfer.com) and actively maintained.

Cons:
* The Json format is not human-friendly.
* "atdgen" does not target other languages besides Ocaml (but this could be
fixed, or in principle, you could hack the plugin to use another
serialization library).
* Some C++ constructions are not fully exported yet.
* Not a standalone tool yet (this causes some overheads -- work in
progress).
* Not considered stable. Everything may change.

-- Mathieu

2015-09-28 7:31 GMT-07:00 Manuel Klimek via cfe-dev <cfe-dev at lists.llvm.org>
:

> On Mon, Sep 28, 2015 at 4:00 PM Bhargava Shastry <
> bshastry at sec.t-labs.tu-berlin.de> wrote:
>
>> > The question is what you want to do; if we're talking IDE support, we
>> > don't want every IDE to go and fiddle with the clang AST - it's complex
>> > and hard to get right.
>> > Instead, we want to build tools in clang/clang-tools-extra, and export
>> > those via libclang (or something similar). That way, all IDEs will have
>> > a common set of well-tested tools.
>> > If you want to build your own one-of code transformation, I'd recommend
>> > to write it in C++ against the clang AST directly.
>>
>> I am working on a close-to-source on-disk representation of clang AST.
>
>
> I understand that - my question is what you want to use it for.
>
>
>> I
>> am unsure what level of AST detail is necessary. But I do know that the
>> detail offered by python bindings is too abstract (low level of detail)
>> for my needs.
>>
>> Is the libclang project you speak of (clang-tidy abstraction) in
>> development or planned for the future? It sounds like an apt setting to
>> implement Bjarne Stroustrup's coding guidelines [1] that he discusses in
>> his latest cppcon talk!
>>
>
> Yes, clang-tidy exists and already has implemented a couple of the core
> guidelines - contributions to implement more checks from the guidelines
> would be highly appreciated.
>
> Note that clang-tidy is not exposed through libclang yet.
>
>
>>
>> [1] https://github.com/isocpp/CppCoreGuidelines
>>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150928/cb641c0a/attachment.html>


More information about the cfe-dev mailing list