[cfe-dev] Exporting Clang AST

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 28 06:41:14 PDT 2015

On Mon, Sep 28, 2015 at 3:37 PM Bhargava Shastry <
bshastry at sec.t-labs.tu-berlin.de> wrote:

> > It is always *a* parent, yes :)
> Hmm... okay. That's something I hadn't imagined in my head about an AST.
> That a node can have multiple parents :/
> Just to be clear, getParents(childNode) returns an array of parents
> only, right i.e., one indentation level up in -ast-dump output? E.g., an
> entry stmt in functiondecl scope has functiondecl as its parent and
> *not* translationunitdecl?


> > Our idea for IDE integration is to export everything that makes sense
> > through libclang (for example, we want to export clang-tidy through
> > libclang, and once we have refactorings, it might make sense to offer
> > them through libclang, too).
> Okay. I did try using libclang python bindings but the AST it exposes
> currently is inferior to what one could get with a libtooling based tool.
> Is AST provided by libclang *proper* (C binding) better than its python
> counterpart? I suppose I mean: Is this a rough ordering from rich to
> poor AST detail?
> Stand-alone tool > libclang > py libclang

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.

> Thanks,
> Bhargava
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150928/14e2ea9c/attachment.html>

More information about the cfe-dev mailing list