[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
core dump.

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.

Best regards,

-- 











*______________________________ <http://www.tallertechnologies.com>Pablo
Miguel OlivaSoftware EngineerSan Lorenzo 47, 3rd Floor, Office 5Córdoba,
Argentina Phone: +54 351 4217888 / +54 351 4218211Skype: pabloliva87*
*Linkedin: ar.linkedin.com/in/pablomigueloliva
<http://ar.linkedin.com/in/pablomigueloliva>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160428/ecd51162/attachment.html>


More information about the cfe-dev mailing list