using clang for refactoring tool

I’m not new to clang, but i still need some help. I’d like to develop a simple (interactive) refactoring tool, and i’ve checked the clang AST API.
How can i hold the AST in memory ? should i use ParseAST function with my custom ASTConsumer what stores the Declarations ?
Are the AST roots the TopLevelDecls ?
Who owns the top level decls ?

thanks for help


We do refactoring of objective-c to c. You can look at Driver/RewriteTest.cpp to see one such refactoring.

- Fariborz