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?
Thank a lot.