On Tue, May 28, 2013 at 11:31 AM, steveneliuk <span dir="ltr"><<a href="mailto:s.eliuk@samsung.com" target="_blank">s.eliuk@samsung.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Clang parses and constructs an AST quickly & effectively... likewise provides<br>
wonderful tools for traversing the AST with ease. Utilizing these tools<br>
provides a lot of the functionality required in the WebCL validator<br>
<br>
Matchers provide a nice way to quickly navigate to nodes of interest, but<br>
the modifications and consistency of the AST is not achievable through<br>
matchers.<br></blockquote><div><br></div><div>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.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Furthermore, if one wants to do some analysis on the modified source it<br>
seems to be the only way to achieve this is to modify the AST.<br></blockquote><div><br></div><div>You could perform the modifications, re-parse the output, and then analyze it.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

The readable output is not required,</blockquote><div><br></div><div>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.</div>
</div>