using clang for refactoring tool

Hi!
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

Cheers,
Csaba

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

- Fariborz