[cfe-dev] get live variables in a refactoring tool
Pei-Shiang Hung
pshung807 at gmail.com
Mon May 4 03:30:01 PDT 2015
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.
More information about the cfe-dev
mailing list