本文整理汇总了C++中CFGNode::addPrev方法的典型用法代码示例。如果您正苦于以下问题:C++ CFGNode::addPrev方法的具体用法?C++ CFGNode::addPrev怎么用?C++ CFGNode::addPrev使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFGNode
的用法示例。
在下文中一共展示了CFGNode::addPrev方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSucc
void ProgramCFG::createSucc(BasicBlock *v){
(*colors)[v] = GRAY;
std::vector<CFGNode*> currentNodes ;
//currentNodes is a node list in which nodes are waiting for find succ.
currentNodes.push_back(&((*nodes)[v]));//first currentNodes is v
//errs()<<dfscount++<<" dfs: "<<(*nodes)[v].name<<"\n";
for(BasicBlock::iterator inst = v->begin(); inst != v->end(); inst ++){
//errs() << *inst<<"\n";
if(CallInst* call = dyn_cast<CallInst>(inst)){
if(isa<UnreachableInst>(++inst)){//exit ,abort ,xalloc_die, program exit.
// errs()<< *(--inst)<<"\n";
goto finish;
}
--inst;
Function *f = call->getCalledFunction();
//If there is a call asm instruction or function pointer call,
// the return value of getCalledFunction will be null.
//So we just ignore it.
if(!f){
// errs() << "Find a CallInst: "<< *inst <<"\n" << "But can't find which function it calls.\n";
continue;
}
if(f->isDeclaration()) {
// errs()<<"isDeclaration " << f->getName() << "\n";
continue;
}else{
// errs() << "hasDefinition " << f->getName() << "\n";
}
//only concerns the function in the targetFunctionList
// if(targetFunctionList->find(f) == targetFunctionList->end()) continue;
// errs() << "find a call : "<< f->getName() << "\n ";
BasicBlock *entry = &f->getEntryBlock();
CFGNode *entryNode = &((*nodes)[entry]);//f's EntryBlock
while(!currentNodes.empty()){
//link succ and prev to each other
currentNodes.back()->addSucc(entryNode);
entryNode->addPrev(currentNodes.back());
currentNodes.pop_back();
}
if((*colors)[entry] == WHITE){//dfs
createSucc(entry);
}
for(std::vector<BasicBlock*>::iterator ret= (*retBlocks)[f].begin();
ret != (*retBlocks)[f].end();
ret++){
currentNodes.push_back(&((*nodes)[*ret]));
}
}
}
//assert(currentNodes.size()==1);
while(!currentNodes.empty()){
CFGNode* current = currentNodes.back();
currentNodes.pop_back();
for(succ_iterator succ = succ_begin(v),end = succ_end(v);
succ != end;
succ++){
CFGNode *succNode = &((*nodes)[*succ]);
current->addSucc(succNode);
succNode->addPrev(current);
if((*colors)[*succ] == WHITE){
createSucc(*succ);
}
}
}
finish:
//errs()<<"dfs back\n";
(*colors)[v] = BLACK;
}