[cfe-dev] about AST of clang

Zhe Chen mr.zhechen at gmail.com
Sun Apr 22 05:11:06 PDT 2012

If I want to do some instrumentation on C source codes, i.e. insert
some statements into the codes, I think that the best way may be the
following one: analysis the generated AST, find appropriate insert
points, and then directly modify the source code using
source-to-source transformations which preserve comments and so on,
since there is a perfect mapping between AST nodes and the source

And, according to the above discussions, directly modifying AST nodes
is not practical, due to the consistency problem of the modified AST.

Is this conclusion correct? Any other opinion?

More information about the cfe-dev mailing list