本文整理汇总了C++中OwningPtr::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ OwningPtr::begin方法的具体用法?C++ OwningPtr::begin怎么用?C++ OwningPtr::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwningPtr
的用法示例。
在下文中一共展示了OwningPtr::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
if(argc < 2)
error("Missing file name.");
LLVMContext context;
SMDiagnostic diag;
OwningPtr<Module> module;
module.reset(ParseIRFile(argv[1], diag, context));
if(!module.get())
error("Failed to load IR.");
for(Module::iterator iter = module->begin(); iter != module->end(); iter++) {
Function *func = iter;
char *name = (char *)malloc(1024);
size_t len = 1024;
int err;
name = abi::__cxa_demangle(func->getName().data(), name, &len, &err);
if(err)
continue;
name[strlen(name)-2] = '\0';
for(Function::iterator iter = func->begin(); iter != func->end(); iter++) {
BasicBlock *block = iter;
for(BasicBlock::iterator iter = block->begin(); iter != block->end(); iter++) {
Instruction *inst = iter;
if(inst->getOpcode() != Instruction::PtrToInt)
continue;
DILocation loc(inst->getMetadata("dbg"));
printf("%s:%u\n", loc.getFilename().data(), loc.getLineNumber());
}
}
free(name);
}
return 0;
}
示例2: main
//.........这里部分代码省略.........
Passes.add(new LoopPassPrinter(PassInf, Out->os()));
break;
case PT_Function:
Passes.add(new FunctionPassPrinter(PassInf, Out->os()));
break;
case PT_CallGraphSCC:
Passes.add(new CallGraphSCCPassPrinter(PassInf, Out->os()));
break;
default:
Passes.add(new ModulePassPrinter(PassInf, Out->os()));
break;
}
}
}
if (PrintEachXForm)
Passes.add(createPrintModulePass(&errs()));
}
// If -std-compile-opts was specified at the end of the pass list, add them.
if (StandardCompileOpts) {
AddStandardCompilePasses(Passes);
StandardCompileOpts = false;
}
if (StandardLinkOpts) {
AddStandardLinkPasses(Passes);
StandardLinkOpts = false;
}
if (OptLevelO1)
AddOptimizationPasses(Passes, *FPasses, 1, 0);
if (OptLevelO2)
AddOptimizationPasses(Passes, *FPasses, 2, 0);
if (OptLevelOs)
AddOptimizationPasses(Passes, *FPasses, 2, 1);
if (OptLevelOz)
AddOptimizationPasses(Passes, *FPasses, 2, 2);
if (OptLevelO3)
AddOptimizationPasses(Passes, *FPasses, 3, 0);
if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
FPasses->doInitialization();
for (Module::iterator F = M->begin(), E = M->end(); F != E; ++F)
FPasses->run(*F);
FPasses->doFinalization();
}
// @LOCALMOD-BEGIN
if (PNaClABISimplifyPreOpt)
PNaClABISimplifyAddPreOptPasses(Passes);
if (PNaClABISimplifyPostOpt)
PNaClABISimplifyAddPostOptPasses(Passes);
// @LOCALMOD-END
// Check that the module is well formed on completion of optimization
if (!NoVerify && !VerifyEach)
Passes.add(createVerifierPass());
// Write bitcode or assembly to the output as the last step...
if (!NoOutput && !AnalyzeOnly) {
if (OutputAssembly)
Passes.add(createPrintModulePass(&Out->os()));
// @LOCALMOD
}
// Before executing passes, print the final values of the LLVM options.
cl::PrintOptionValues();
// Now that we have all of the passes ready, run them.
Passes.run(*M.get());
// @LOCALMOD-BEGIN
// Write bitcode to the output.
if (!NoOutput && !AnalyzeOnly && !OutputAssembly) {
switch (OutputFileFormat) {
case LLVMFormat:
WriteBitcodeToFile(M.get(), Out->os());
break;
case PNaClFormat:
NaClWriteBitcodeToFile(M.get(), Out->os());
break;
default:
errs() << "Don't understand bitcode format for generated bitcode.\n";
return 1;
}
}
// @LOCALMOD-END
// Declare success.
if (!NoOutput || PrintBreakpoints)
Out->keep();
return 0;
}