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


C++ iterator::empty方法代码示例

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


在下文中一共展示了iterator::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findFunctionScopedAllocas

/// findFunctionScopedAllocas - store all allocas that are known to be valid
/// to the end of their function in a set. The current algorithm does this by
/// finding all the allocas in the entry block that are before the first
/// llvm.stacksave call (if any).
///
/// FIXME: There can also be allocas elsewhere that get deallocated at the end
/// of the function but they are pessimistically ignored for now.
///
void ExactCheckOpt::findFunctionScopedAllocas(Module &M) {
  for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
    if (F->empty())
      continue;

    BasicBlock &BB = F->getEntryBlock();
    for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
      if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
        FunctionScopedAllocas.insert(AI);
      } else if(CallInst *CI = dyn_cast<CallInst>(I)) {
        Function *CalledFunction = CI->getCalledFunction();
        if (CalledFunction && CalledFunction->getName() == "llvm.stacksave")
          break;
      }
    }
  }
}
开发者ID:otinn,项目名称:safecode,代码行数:25,代码来源:ExactCheckOpt.cpp

示例2: runOnModule

bool TraceBasicBlocks::runOnModule(Module &M)  {
	Context =&M.getContext();
	Function *Main = M.getFunction("main");
	if (Main == 0) {
		errs() << "WARNING: cannot insert basic-block trace instrumentation"
			<< " into a module with no main function!\n";
		return false;  // No main, no instrumentation!
	}
	const char* FnName="llvm_trace_basic_block";
	Constant *InstrFn = M.getOrInsertFunction (FnName, Type::getVoidTy(*Context),
	                                           Type::getInt64Ty(*Context), NULL);

	unsigned BBNumber = 0;
	for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
		if(F->empty()) { continue; }
		//We insert instrumentation calls in reverse order, because insertion puts them before previous instructions
		for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
			dbgs() << "InsertInstrumentationCall (\"" << BB->getName ()
				<< "\", \"" << F->getName() << "\", " << BBNumber << ")\n";

			//On Exit we emit the FunRet block
			TerminatorInst* TI=BB->getTerminator();
			if(TI->getNumSuccessors()==0) {
				InsertRetInstrumentationCall(TI,InstrFn);
			}
			InsertInstrumentationCall (BB, InstrFn, BBNumber);
			if(TraceMemory) {
				InsertMemoryTracingCall (BB,InstrFn);
			}
			++BBNumber;
		}
		//on Entry we emit the FunCall block.
		BasicBlock* EntryBlock=&F->getEntryBlock();
		InsertInstrumentationCall (EntryBlock, InstrFn, BBTraceStream::FunCallID);
	}

	// Add the initialization call to main.

	InsertProfilingInitCall(Main, "llvm_start_basic_block_tracing");
	return true;
}
开发者ID:UIKit0,项目名称:LLVM_IRProfiling,代码行数:41,代码来源:TraceBasicBlocks.cpp


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