当前位置: 首页>>代码示例>>C++>>正文


C++ CFGNode::addSucc方法代码示例

本文整理汇总了C++中CFGNode::addSucc方法的典型用法代码示例。如果您正苦于以下问题:C++ CFGNode::addSucc方法的具体用法?C++ CFGNode::addSucc怎么用?C++ CFGNode::addSucc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFGNode的用法示例。


在下文中一共展示了CFGNode::addSucc方法的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;
}
开发者ID:YichaoLee,项目名称:Checker,代码行数:81,代码来源:programCFG.cpp


注:本文中的CFGNode::addSucc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。