aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/FunctionResolution.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-01-30 22:38:44 +0000
committerChris Lattner <sabre@nondot.org>2003-01-30 22:38:44 +0000
commit49f201214055c8eaffa3eef91b87c4997afadc45 (patch)
tree89c57f2ff9a856717e8b32bf8d8be7e58ff45c57 /lib/Transforms/IPO/FunctionResolution.cpp
parentbae362f8fcbaa772a4cfb26aeb716079b5b08336 (diff)
Fix a bug resolving sprintf(...) to sprintf(char*, char*, ...)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5446 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/FunctionResolution.cpp')
-rw-r--r--lib/Transforms/IPO/FunctionResolution.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp
index 9527ad2135..9c5580b3b2 100644
--- a/lib/Transforms/IPO/FunctionResolution.cpp
+++ b/lib/Transforms/IPO/FunctionResolution.cpp
@@ -48,7 +48,10 @@ static void ConvertCallTo(CallInst *CI, Function *Dest) {
// argument types don't agree.
//
BasicBlock::iterator BBI = CI;
- if (CI->getNumOperands()-1 != ParamTys.size()) {
+ unsigned NumArgsToCopy = CI->getNumOperands()-1;
+ if (CI->getNumOperands()-1 != ParamTys.size() &&
+ !(CI->getNumOperands()-1 > ParamTys.size() &&
+ Dest->getFunctionType()->isVarArg())) {
std::cerr << "WARNING: Call arguments do not match expected number of"
<< " parameters.\n";
std::cerr << "WARNING: In function '"
@@ -62,11 +65,13 @@ static void ConvertCallTo(CallInst *CI, Function *Dest) {
// Convert all of the call arguments over... inserting cast instructions if
// the types are not compatible.
- for (unsigned i = 1; i <= ParamTys.size(); ++i) {
+ for (unsigned i = 1; i <= NumArgsToCopy; ++i) {
Value *V = CI->getOperand(i);
- if (V->getType() != ParamTys[i-1]) // Must insert a cast...
+ if (i-1 < ParamTys.size() && V->getType() != ParamTys[i-1]) {
+ // Must insert a cast...
V = new CastInst(V, ParamTys[i-1], "argcast", BBI);
+ }
Params.push_back(V);
}