diff options
author | Chris Lattner <sabre@nondot.org> | 2004-06-03 06:38:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-06-03 06:38:43 +0000 |
commit | 7c277b3a6453dd81ad480c4fcf49a3a01f3e0f62 (patch) | |
tree | 5dd1ac437b1bcd5174fc6977238415add049f3d6 | |
parent | 8c4174a0a73e5f8716f6741f39d69f726c7df6cb (diff) | |
download | external_llvm-7c277b3a6453dd81ad480c4fcf49a3a01f3e0f62.zip external_llvm-7c277b3a6453dd81ad480c4fcf49a3a01f3e0f62.tar.gz external_llvm-7c277b3a6453dd81ad480c4fcf49a3a01f3e0f62.tar.bz2 |
* Verify function prototypes, not just functions with bodies.
* Verify that functions do not take aggregates as arguments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13984 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Verifier.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index e2d6b63..2e92c26 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -112,12 +112,18 @@ namespace { // Anonymous namespace for class bool doFinalization(Module &M) { // Scan through, checking all of the external function's linkage now... - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { visitGlobalValue(*I); + // Check to make sure function prototypes are okay. + if (I->isExternal()) visitFunction(*I); + } + for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) visitGlobalValue(*I); + + // If the module is broken, abort at this time. abortIfBroken(); return false; @@ -284,10 +290,14 @@ void Verifier::visitFunction(Function &F) { // Check that the argument values match the function type for this function... unsigned i = 0; - for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I, ++i) + for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I, ++i) { Assert2(I->getType() == FT->getParamType(i), "Argument value does not match function argument type!", I, FT->getParamType(i)); + // Make sure no aggregates are passed by value. + Assert1(I->getType()->isFirstClassType(), + "Functions cannot take aggregates as arguments by value!", I); + } if (!F.isExternal()) { verifySymbolTable(F.getSymbolTable()); |