'How to get the information of DeclRefExpr from the basic block in Clang:CFG?
How to get the information of DeclRefExpr from the basic block in Clang:CFG? This is code i have coded
class CFGPrinter : public MatchFinder::MatchCallback {
public:
virtual void run(const MatchFinder::MatchResult &Result) {
if (const FunctionDecl *funcDecl =
Result.Nodes.getNodeAs<clang::FunctionDecl>("mainFunction")) {
ASTContext *context = Result.Context;
Stmt *funcBody = funcDecl->getBody();
static std::unique_ptr<CFG> sourceCFG = CFG::buildCFG(funcDecl, funcBody, context, clang::CFG::BuildOptions());
for(CFG::const_iterator it = sourceCFG->begin(), ei = sourceCFG->end(); it != ei; ++it){
const CFGBlock* block = *it;
for(CFGBlock::const_iterator bi = block->begin(), be = block->end(); bi != be; ++bi){
const CFGElement &elem = *bi;
const Stmt *stmt_tmp = elem.castAs<CFGStmt>().getStmt();
/*I want to get DeclRefExpr from next*/
}
}
}
}
}
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|