diff options
author | Chris Lattner <sabre@nondot.org> | 2003-01-30 22:38:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-01-30 22:38:44 +0000 |
commit | 68f63f779c1e19007bb1d3efc70c246ff67dc606 (patch) | |
tree | f170312f87f03d1c817a8023333d165259debad7 /llvm/lib/Transforms | |
parent | 63a25242dcc6870b566d63be4b936ad1a952c9d1 (diff) | |
download | bcm5719-llvm-68f63f779c1e19007bb1d3efc70c246ff67dc606.tar.gz bcm5719-llvm-68f63f779c1e19007bb1d3efc70c246ff67dc606.zip |
Fix a bug resolving sprintf(...) to sprintf(char*, char*, ...)
llvm-svn: 5446
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionResolution.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionResolution.cpp b/llvm/lib/Transforms/IPO/FunctionResolution.cpp index 9527ad2135c..9c5580b3b26 100644 --- a/llvm/lib/Transforms/IPO/FunctionResolution.cpp +++ b/llvm/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); } |