[cfe-dev] Failure to rewrite code using clang plugin
Pablo Oliva via cfe-dev
cfe-dev at lists.llvm.org
Thu Apr 28 13:48:13 PDT 2016
Hi, as part of a research project I had to tag certain typedefs with an
attribute and then replace those tagged typedefs by some specific code.
I added the attribute to include/clang/Basic/Attr.td, recompiled clang, and
then programmed a plugin using ASTMatchers, to detect all the typedefs and
do the replacement (using Rewriter) if the attribute is present.
Now, if I use the plugin passing -XClang -plugin as compilation arguments,
so that the compilation stops after using the plugin, the plugin works
correctly and outputs modified source code. But if I use -XClang
-add-plugin, so that the compilation carries on, Rewriter fails and I get a
Am I doing something wrong in here? Is Rewriter unusable unless it is used
as a plugin? If you were to do some transformation similar to this one,
would you use a similar strategy or do things differently?
Any advice would be greatly welcomed.
Miguel OlivaSoftware EngineerSan Lorenzo 47, 3rd Floor, Office 5Córdoba,
Argentina Phone: +54 351 4217888 / +54 351 4218211Skype: pabloliva87*
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev