[cfe-dev] Mutable AST -- Advice Needed --

Richard Smith richard at metafoo.co.uk
Tue May 28 11:42:29 PDT 2013

On Tue, May 28, 2013 at 11:31 AM, steveneliuk <s.eliuk at samsung.com> wrote:

> Clang parses and constructs an AST quickly & effectively... likewise
> provides
> wonderful tools for traversing the AST with ease. Utilizing these tools
> provides a lot of the functionality required in the WebCL validator
> Matchers provide a nice way to quickly navigate to nodes of interest, but
> the modifications and consistency of the AST is not achievable through
> matchers.

Consistency of the AST is significantly harder to achieve through direct
AST manipulation than through source rewriting. There are various forms of
implicitly-added AST nodes that you would need to create, and you would
need to ensure that your nodes have appropriate type, value kind, and so
on. None of this is necessary if you use the rewrite interface.

Furthermore, if one wants to do some analysis on the modified source it
> seems to be the only way to achieve this is to modify the AST.

You could perform the modifications, re-parse the output, and then analyze

The readable output is not required,

This opens up some other avenues; for instance, you could implement your
transformation as a set of LLVM IR passes, and add an OpenCL backend to
generate code from the IR.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130528/e877e7c2/attachment.html>

More information about the cfe-dev mailing list