get live variables in a refactoring tool

Dears,

I'm writing a refactoring tool with clang libtooling.

What I need is to rewrite source code according to live variable
information. For example, for each basic block in a function, dump its
live-out variables.

I know it would be quite easily if I'm writing an analysis checker.

void checkASTCodeBody(const Decl *D, AnalysisManager& mgr,
                    BugReporter &BR) const {
if (LiveVariables* L = mgr.getAnalysis<LiveVariables>(D)) {
  L->dumpBlockLiveness(mgr.getSourceManager());
}
}

simplely call mgr.getAnalysis(D) to get LiveVariables of this
function. then, dump each block.

But, I'm writing a standalone refactoring tool. How can I construct an
AnalysisManager object?
Are there any reference?

Thank a lot.

Heya, I think you’re the first one to try this out - I’ve had it on my TODO list for a long time, but it’s never made it to the top.