On 5 October 2014 03:39, Adrian May <adrian.alexander....@gmail.com> wrote: > But it absolutely has to follow the preprocessor, so how do I do that? > I'm a bit surprised about that being a problem cos when I look at > preprocessor output it looks very convenient - I get one big file but > it's full of clues as to where it all came from. Perhaps I have to > hook those clues.
Precisely. The information is there. The only open question is how to pass it to your plugin. See libcpp/macro.c and libcpp/include/cpplib.h and look for "callback". Then check init_c_lex in c-family/c-lex.c to see how the C/C++ FE uses them. Now you have to figure out which plugin hook your plugin should handle in order to take control of the callbacks before they are used. If nothing is early enough, you would need to add a new hook. (At least, this is what I would try first, perhaps there is even a better way). Cheers, Manuel.