本文整理汇总了C++中basicblock::iterator::eraseFromParent方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::eraseFromParent方法的具体用法?C++ iterator::eraseFromParent怎么用?C++ iterator::eraseFromParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类basicblock::iterator
的用法示例。
在下文中一共展示了iterator::eraseFromParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOnFunction
virtual bool runOnFunction(Function& f)
{
CurrentFile::set(__FILE__);
bool changed = false;
// Make sure this is a function that we can use
if (f.isDeclaration() /*|| !f.isDFFunction()*/ )
{
return changed ;
}
for(Function::iterator BB = f.begin(); BB != f.end(); ++BB)
{
begin:
for(BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II)
{
if( !dynamic_cast<TerminatorInst*>(&*II) )
{
II->replaceAllUsesWith(UndefValue::get(II->getType()));
II->eraseFromParent();
goto begin;
}
}
}
changed = true;
return changed;
}
示例2: ConvertCmp
void MakeDispatcherPass::ConvertCmp(Function& function)
{
typedef std::vector< Instruction * > InstList;
InstList insts;
for (Function::iterator BB = function.begin(), bbE = function.end(); BB != bbE; ++BB)
{
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;)
{
if (isa< CmpInst >(I))
{
insts.push_back(I);
}
if (isa< BranchInst >(I))
{
BasicBlock::iterator save = I;
BranchInst* branchInst = dynamic_cast< BranchInst *>(&*I);
if (branchInst->isConditional() && !insts.empty())
{
Value* valbranch = NULL;
valbranch = branchInst->getCondition();
ShowType(dynamic_cast<CmpInst*>(insts[0]));
CreateInt3(BB, I);
I++;
save->eraseFromParent();
insts.pop_back();
continue;
}
}
I++;
}
}
}
示例3: runOnModule
bool EraseUclibcFiniPass::runOnModule(Module &M) {
Function *f = M.getFunction("tern_exit");
Function *fini = M.getFunction("__uClibc_fini");
if(!f || !fini)
return false;
for (Function::iterator b = f->begin(), be = f->end(); b != be; ++b) {
for (BasicBlock::iterator i = b->begin(), ie = b->end(); i != ie; ++i) {
if (i->getOpcode() == Instruction::Call) {
CallInst *ci = dyn_cast<CallInst>(i);
assert(ci);
if (ci->getCalledFunction() == fini) {
i->eraseFromParent();
return true;
}
}
}
}
return false;
}