[cfe-dev] Bug 11806

Richard Smith richard at metafoo.co.uk
Sun Oct 7 14:37:25 PDT 2012


On Sun, Oct 7, 2012 at 2:17 PM, Grzegorz Jablonski <grzejabl at gmail.com>wrote:

> Hi,
>
> there is a bug http://llvm.org/bugs/show_bug.**cgi?id=11806<http://llvm.org/bugs/show_bug.cgi?id=11806>about -ast-print not being production quality. I am using clang to rewrite
> C++ source. Is anyone else using clang in that way? Some comments on the
> bug pages suggest, that nobody is using this feature.
>

Yes, various people use Clang to rewrite C++ source, but mainly not by
pretty-printing. Instead, targeted rewrites are performed on the original
source file in each place that needs to be changed (see the Rewriter
class). This has the advantage of preserving source formatting, comments,
macros, header inclusions, etc. Generally speaking, pretty-printing isn't a
good way to perform rewrites if you want to produce code for a person to
maintain, because it loses all this information. Also, since the AST is
intended to be essentially immutable, if you want to perform rewrites you
are likely to find it easier to perform them textually rather than writing
a pass to build a rewritten AST.

That said, making the AST pretty-printing more correct would be a good
thing. Patches attached to bugs are not likely to get much attention;
instead, you should mail the patches to cfe-commits at cs.uiuc.edu and ask for
them to be reviewed / committed.
-- 
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121007/5b7efc88/attachment.html>


More information about the cfe-dev mailing list