diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-04 21:03:58 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-04 21:03:58 -0700 |
commit | 70fa5e76093e7566e92786d5cc25ef1792b7cea1 (patch) | |
tree | a81c1a48f14080dad5648f624d7ca9caf493066b /lib | |
parent | 51c0650c7bb78fed8ce0aba537312aea17f58d7d (diff) |
PNaCl ABI checker: Reject functions that are declared but not defined
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3339
TEST=*.ll tests + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/16270007
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index 364614f9a2..7daeabd0e8 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -346,22 +346,26 @@ bool PNaClABIVerifyModule::runOnModule(Module &M) { } for (Module::const_iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { - // Check intrinsics. - if (MI->isIntrinsic() - && !isWhitelistedIntrinsic(MI, MI->getIntrinsicID())) { - Reporter->addError() << "Function " << MI->getName() - << " is a disallowed LLVM intrinsic\n"; - } - - // 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 (!MI->isIntrinsic() && - !PNaClABITypeChecker::isValidFunctionType(MI->getFunctionType())) { - Reporter->addError() << "Function " << MI->getName() - << " has disallowed type: " - << PNaClABITypeChecker::getTypeName(MI->getFunctionType()) - << "\n"; + 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"; + } + if (MI->isDeclaration()) { + Reporter->addError() << "Function " << MI->getName() + << " is declared but not defined (disallowed)\n"; + } } checkGlobalValueCommon(MI); |