[cfe-dev] Rewriter in a macro

Manuel Klimek klimek at google.com
Tue Jan 29 04:39:52 PST 2013


On Sat, Jan 26, 2013 at 12:52 PM, JohnH <jan.hoogerbrugge at gmail.com> wrote:

> The result of rewriting should be preprocessed code. I can imagine that
> there
> are applications where
> you want unpreprocessed output so perhaps the Rewriter class should have
> the
> option to work in
> the preprocessed and the unpreprocessed domain.
>

As far as I understand, the Rewriter works on the actual source code. We've
done refactorings which work inside macros without problems - the hard part
is getting the right source locations, the Rewriter deals with whatever
source locations you throw at it.

Clang has in principle all information you need to deal with macros, but
sometimes it's hard to get to them :)
You'll obviously not be able to refactor arbitrarily crazy token-pasted
code, but I've not seen this to be a problem in practice.

Similar problems exist with templates, by the way: for example, if you want
to rename Foo::f to Foo::g, and you instantiate a template with Foo which
calls f(), you cannot figure out in general whether renaming the call to
f() is correct.

Cheers,
/Manuel


> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/Rewriter-in-a-macro-tp4030056p4030078.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130129/8fd74143/attachment.html>


More information about the cfe-dev mailing list