[cfe-dev] preferred way to translate and output source code?

Michael Kruse via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 23 09:41:08 PDT 2018

The Rewriter is useful if you want to make small changes and keep the
remaining untouched (formatting, whitespace, ...). If you target a
different language, you probably do not want/need to preserve
anything, so a recursive traversal is the right thing to do. It also
saves you from having to handle #include and forward declarations,
which probably do not have the same semantics in your target language.

"Probably", because there are two language rewriters in clang:
RewriteObjC/RewriteModernObjC (Objective C -> C) and HTMLRewriter
(ObjC/C/C++ -> HTML)


Am Di., 23. Okt. 2018 um 03:59 Uhr schrieb Lou Wynn via cfe-dev
<cfe-dev at lists.llvm.org>:
> Hi,
> I'm writing a source to source translation tool which accepts Clang AST and outputs source code of another language. My original plan was to traverse the AST of a translation unit and outputs corresponding source code of the target language, but I've noticed that there is a Rewriter and I'm not sure if the Rewriter works for my purpose.
> I've just started using Clang AST, and I appreciate any suggestion and example.
> --
> Love,
> Lou
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list