<div dir="ltr">Hi all,<br><br>Not sure if it's the right place for this kind of questions, if not- please refer me to the right place.<br>I want to use clang to manipulate AST of a c++ source, and write back the modified source to an output file.<br>
I'm trying to get familiar with clang and llvm for 2 weeks now, but having problems since all tutorials I found are outdated,<br>and so is the <a href="http://clang.llvm.org/doxygen/">API</a>.<br><br>I've managed to run some tutorial which changes function names thru ASTConsumer implementation,<br>
which calls the Visit method of DeclVisitor class, and the manipultion is done in the VisitFunctionDecl method.<br>Basically I'm able retrieve pretty much all I need from the AST.<br><br>My problem is modifying the AST:<br>
1. Alter function signutures (type and params), <br>2. Adding a statement or a declaration to a block (both global and in function scope). <br>i.e. a function or variable declaration, a conditional statement.<br clear="all">
<br>I'll be grateful if someone could give me a concrete example how to do the above operation.<br><br><br>Thanks in advance,<br>Ilya<br> <br>-- <br><div dir="ltr">Best Regards,<br>Ilya Mirsky<br><a href="http://www.cs.bgu.ac.il/%7Emirskyil" target="_blank">www.cs.bgu.ac.il/~mirskyil</a><br>
</div><br>
</div>