building Code from clangAST

Hello All
I'm new in clang and llvm please help me.
I'm writing a c++ code obfuscator. I'm applying some data and control
obfuscations.
So I know how to parse code and build AST tree.. but I don't know how to
convert my modified AST tree to code again. can anyone write a sample code?
clang is a jungle of code and it's hard to find a way by just reading codes.
thanks in advanced..

Hi,

I’m not really clear on why would you need to obfuscate C++ code, but check out clang-format (http://clang.llvm.org/docs/ClangFormat.html), might help you with what you need.

As far as I know there is no direct way to write the AST back to C++ code, and so I think you’ll need to make do with the Rewriter and/or tooling::Replacement classes. See the doxygen documentation for details.

Gabor