本文整理汇总了C++中module::const_iterator::getCallingConv方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::getCallingConv方法的具体用法?C++ const_iterator::getCallingConv怎么用?C++ const_iterator::getCallingConv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::const_iterator
的用法示例。
在下文中一共展示了const_iterator::getCallingConv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteModuleInfo
// Emit top-level description of module, including inline asm,
// descriptors for global variables, and function prototype info.
static void WriteModuleInfo(const Module *M, const NaClValueEnumerator &VE,
NaClBitstreamWriter &Stream) {
DEBUG(dbgs() << "-> WriteModuleInfo\n");
// Emit the function proto information. Note: We do this before
// global variables, so that global variable initializations can
// refer to the functions without a forward reference.
SmallVector<unsigned, 64> Vals;
for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F) {
// FUNCTION: [type, callingconv, isproto, linkage]
Type *Ty = F->getType()->getPointerElementType();
Vals.push_back(VE.getTypeID(Ty));
Vals.push_back(GetEncodedCallingConv(F->getCallingConv()));
Vals.push_back(F->isDeclaration());
Vals.push_back(getEncodedLinkage(F));
unsigned AbbrevToUse = 0;
Stream.EmitRecord(naclbitc::MODULE_CODE_FUNCTION, Vals, AbbrevToUse);
Vals.clear();
}
// Emit the global variable information.
WriteGlobalVars(M, VE, Stream);
DEBUG(dbgs() << "<- WriteModuleInfo\n");
}
示例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;
}