aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-03 00:48:22 +0000
committerChris Lattner <sabre@nondot.org>2006-05-03 00:48:22 +0000
commit9b4c96d45dfeda453709478286bcc5e6b784aca4 (patch)
tree44f78cbf8474fe629591896cf3da9324d75b860b /lib/VMCore/Instructions.cpp
parentaf1563fb62ed76f4818ac172ab1c6cf15fa35a82 (diff)
Add assertions that verify that the actual arguments to a call or invoke match
the prototype of the called function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28070 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r--lib/VMCore/Instructions.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 6e615159c3..d3c7b54d2a 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -197,9 +197,13 @@ void CallInst::init(Value *Func, const std::vector<Value*> &Params) {
assert((Params.size() == FTy->getNumParams() ||
(FTy->isVarArg() && Params.size() > FTy->getNumParams())) &&
- "Calling a function with bad signature");
- for (unsigned i = 0, e = Params.size(); i != e; ++i)
+ "Calling a function with bad signature!");
+ for (unsigned i = 0, e = Params.size(); i != e; ++i) {
+ assert((i >= FTy->getNumParams() ||
+ FTy->getParamType(i) == Params[i]->getType()) &&
+ "Calling a function with a bad signature!");
OL[i+1].init(Params[i], this);
+ }
}
void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
@@ -213,8 +217,14 @@ void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
assert((FTy->getNumParams() == 2 ||
- (FTy->isVarArg() && FTy->getNumParams() == 0)) &&
+ (FTy->isVarArg() && FTy->getNumParams() < 2)) &&
"Calling a function with bad signature");
+ assert((0 >= FTy->getNumParams() ||
+ FTy->getParamType(0) == Actual1->getType()) &&
+ "Calling a function with a bad signature!");
+ assert((1 >= FTy->getNumParams() ||
+ FTy->getParamType(1) == Actual2->getType()) &&
+ "Calling a function with a bad signature!");
}
void CallInst::init(Value *Func, Value *Actual) {
@@ -229,6 +239,9 @@ void CallInst::init(Value *Func, Value *Actual) {
assert((FTy->getNumParams() == 1 ||
(FTy->isVarArg() && FTy->getNumParams() == 0)) &&
"Calling a function with bad signature");
+ assert((0 == FTy->getNumParams() ||
+ FTy->getParamType(0) == Actual->getType()) &&
+ "Calling a function with a bad signature!");
}
void CallInst::init(Value *Func) {
@@ -339,8 +352,13 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
(FTy->isVarArg() && Params.size() > FTy->getNumParams()) &&
"Calling a function with bad signature");
- for (unsigned i = 0, e = Params.size(); i != e; i++)
+ for (unsigned i = 0, e = Params.size(); i != e; i++) {
+ assert((i >= FTy->getNumParams() ||
+ FTy->getParamType(i) == Params[i]->getType()) &&
+ "Invoking a function with a bad signature!");
+
OL[i+3].init(Params[i], this);
+ }
}
InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal,