How to rewrite macros

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to rewrite macros

Hao Jiang
Hi @clang,
I used clang  rewriter framework to implement a source code translation tool. The main goal of this tool is modify variable reference and CallExpr inside each function body. But I found that rewriter could not modify macros for example:
    msg = (MyMessage*)ic->activeEvent();
    assert(msg);
my tool translate above source code to
    pframe->msg_0 = (MyMessage*)ic->activeEvent();    //change msg to  pframe->msg_0
    assert(msg);                                                           //variable msg inside macro did not change
The variables inside macro never going to be changed. Is there a way to rewrite macros? Any suggestion is appreciated. Thank you.
Hao Jiang