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.