本文整理汇总了C++中module::const_iterator::getFunctionType方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::getFunctionType方法的具体用法?C++ const_iterator::getFunctionType怎么用?C++ const_iterator::getFunctionType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::const_iterator
的用法示例。
在下文中一共展示了const_iterator::getFunctionType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildCallMaps
void buildCallMaps(Module const& M, FunctionsMap& F,
CallsMap& C) {
for (Module::const_iterator f = M.begin(); f != M.end(); ++f) {
if (!f->isDeclaration())
F.insert(std::make_pair(f->getFunctionType(), &*f));
for (Function::const_iterator b = f->begin(); b != f->end(); ++b) {
for (BasicBlock::const_iterator i = b->begin(); i != b->end(); ++i)
if (const CallInst *CI = dyn_cast<CallInst>(&*i)) {
if (!isInlineAssembly(CI) && !callToMemoryManStuff(CI))
C.insert(std::make_pair(getCalleePrototype(CI), CI));
} else if (const StoreInst *SI = dyn_cast<StoreInst>(&*i)) {
const Value *r = SI->getValueOperand();
if (hasExtraReference(r) && memoryManStuff(r)) {
const Function *fn = dyn_cast<Function>(r);
F.insert(std::make_pair(fn->getFunctionType(), fn));
}
}
}
}
}
示例2: runOnModule
bool PNaClABIVerifyModule::runOnModule(Module &M) {
if (!M.getModuleInlineAsm().empty()) {
Reporter->addError() <<
"Module contains disallowed top-level inline assembly\n";
}
for (Module::const_global_iterator MI = M.global_begin(), ME = M.global_end();
MI != ME; ++MI) {
checkGlobalIsFlattened(MI);
checkGlobalValueCommon(MI);
if (MI->isThreadLocal()) {
Reporter->addError() << "Variable " << MI->getName() <<
" has disallowed \"thread_local\" attribute\n";
}
}
// No aliases allowed for now.
for (Module::alias_iterator MI = M.alias_begin(),
E = M.alias_end(); MI != E; ++MI) {
Reporter->addError() << "Variable " << MI->getName() <<
" is an alias (disallowed)\n";
}
for (Module::const_iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) {
if (MI->isIntrinsic()) {
// Check intrinsics.
if (!isWhitelistedIntrinsic(MI, MI->getIntrinsicID())) {
Reporter->addError() << "Function " << MI->getName()
<< " is a disallowed LLVM intrinsic\n";
}
} else {
// Check types of functions and their arguments. Not necessary
// for intrinsics, whose types are fixed anyway, and which have
// argument types that we disallow such as i8.
if (!PNaClABITypeChecker::isValidFunctionType(MI->getFunctionType())) {
Reporter->addError() << "Function " << MI->getName()
<< " has disallowed type: "
<< PNaClABITypeChecker::getTypeName(MI->getFunctionType())
<< "\n";
}
// This check is disabled in streaming mode because it would
// reject a function that is defined but not read in yet.
// Unfortunately this means we simply don't check this property
// when translating a pexe in the browser.
// TODO(mseaborn): Enforce this property in the bitcode reader.
if (!StreamingMode && MI->isDeclaration()) {
Reporter->addError() << "Function " << MI->getName()
<< " is declared but not defined (disallowed)\n";
}
if (!MI->getAttributes().isEmpty()) {
Reporter->addError()
<< "Function " << MI->getName() << " has disallowed attributes:"
<< getAttributesAsString(MI->getAttributes()) << "\n";
}
if (MI->getCallingConv() != CallingConv::C) {
Reporter->addError()
<< "Function " << MI->getName()
<< " has disallowed calling convention: "
<< MI->getCallingConv() << "\n";
}
}
checkGlobalValueCommon(MI);
if (MI->hasGC()) {
Reporter->addError() << "Function " << MI->getName() <<
" has disallowed \"gc\" attribute\n";
}
// Knowledge of what function alignments are useful is
// architecture-specific and sandbox-specific, so PNaCl pexes
// should not be able to specify function alignment.
if (MI->getAlignment() != 0) {
Reporter->addError() << "Function " << MI->getName() <<
" has disallowed \"align\" attribute\n";
}
}
// Check named metadata nodes
for (Module::const_named_metadata_iterator I = M.named_metadata_begin(),
E = M.named_metadata_end(); I != E; ++I) {
if (!isWhitelistedMetadata(I)) {
Reporter->addError() << "Named metadata node " << I->getName()
<< " is disallowed\n";
}
}
Reporter->checkForFatalErrors();
return false;
}