[llvm-commits] CVS: llvm/lib/Transforms/IPO/FunctionResolution.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Jan 30 16:41:48 PST 2003


Changes in directory llvm/lib/Transforms/IPO:

FunctionResolution.cpp updated: 1.19 -> 1.20

---
Log message:

Fix a bug resolving sprintf(...) to sprintf(char*, char*, ...)


---
Diffs of the changes:

Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp
diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.19 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.20
--- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.19	Thu Jan 30 15:33:07 2003
+++ llvm/lib/Transforms/IPO/FunctionResolution.cpp	Thu Jan 30 16:38:44 2003
@@ -48,7 +48,10 @@
   // 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 @@
 
   // 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);
   }





More information about the llvm-commits mailing list