[cfe-dev] [RFC] Easier source-to-source transformations with clang tooling

Joel E. Denny via cfe-dev cfe-dev at lists.llvm.org
Wed Jan 23 15:24:33 PST 2019


Hi Yitzhak,

On Fri, Nov 16, 2018 at 10:22 AM Yitzhak Mandelbaum via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi all,
>
> I have a proposal for a framework that makes it easier to write source to
> source transformations with the clang::Tooling libraries, including
> clang-tidy checks.
>
> The full proposal is in this doc:
>
>
> https://docs.google.com/document/d/1ppw0RhjwsrbBcHYhI85pe6ISDbA6r5d00ot3N8cQWeQ/edit?usp=sharing
>

I just took a quick pass on this document, and it looks interesting.
However, I'm not very familiar with this area of clang, and I have a few
high-level questions to be sure I understand the objectives of your tool.

My understanding is that the input of a transformation using your tool is a
clang AST and the output is new source code.  Is that correct?

If so, it seems your tool is optimized for (but not functionally limited
to) transformations involving a single pass where the ultimate product is
source code.  That is, after running a transformation pass, if you want to
either run additional transformation passes or perform LLVM IR codegen, you
would need to serialize the output as source code and run clang again to
get the new AST.  Is that correct?

Thanks.

Joel


>
> From the doc:
> Transformer is a framework that aims to simplify development of
> clang-based source-to-source transformations.  It focuses on the particular
> class of transformations that act only locally — that is, use local
> information about the code and make local changes  (like a syntax-aware
> “find-and-replace”); and at scale — that is, will be carried out on many
> source files.  The target audience is users that are comfortable with, or
> willing to become comfortable with, the clang AST matchers library.
>
> I have a working prototype of this library which I've used on small
> examples inside Google.  I plan to put together a patch for reference
> next week, although the doc should stand on its own.
>
> Thanks!
> Yitzhak Mandelbaum
> _______________________________________________
> 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/20190123/ac2cf644/attachment.html>


More information about the cfe-dev mailing list