Start using the new and improve interface to FunctionType arguments

llvm-svn: 11224
diff --git a/llvm/lib/Transforms/ExprTypeConvert.cpp b/llvm/lib/Transforms/ExprTypeConvert.cpp
index d46878d..9fc9c93 100644
--- a/llvm/lib/Transforms/ExprTypeConvert.cpp
+++ b/llvm/lib/Transforms/ExprTypeConvert.cpp
@@ -304,8 +304,7 @@
     //
     const PointerType *PT = cast<PointerType>(I->getOperand(0)->getType());
     const FunctionType *FT = cast<FunctionType>(PT->getElementType());
-    std::vector<const Type *> ArgTys(FT->getParamTypes().begin(),
-                                     FT->getParamTypes().end());
+    std::vector<const Type *> ArgTys(FT->param_begin(), FT->param_end());
     const FunctionType *NewTy =
       FunctionType::get(Ty, ArgTys, FT->isVarArg());
     if (!ExpressionConvertibleToType(I->getOperand(0),
@@ -513,8 +512,7 @@
     //
     const PointerType *PT = cast<PointerType>(I->getOperand(0)->getType());
     const FunctionType *FT = cast<FunctionType>(PT->getElementType());
-    std::vector<const Type *> ArgTys(FT->getParamTypes().begin(),
-                                     FT->getParamTypes().end());
+    std::vector<const Type *> ArgTys(FT->param_begin(), FT->param_end());
     const FunctionType *NewTy =
       FunctionType::get(Ty, ArgTys, FT->isVarArg());
     const PointerType *NewPTy = PointerType::get(NewTy);
@@ -862,9 +860,8 @@
       // reason for this is that we prefer to have resolved functions but casted
       // arguments if possible.
       //
-      const FunctionType::ParamTypes &PTs = FTy->getParamTypes();
-      for (unsigned i = 0, NA = PTs.size(); i < NA; ++i)
-        if (!PTs[i]->isLosslesslyConvertibleTo(I->getOperand(i+1)->getType()))
+      for (unsigned i = 0, NA = FTy->getNumParams(); i < NA; ++i)
+        if (!FTy->getParamType(i)->isLosslesslyConvertibleTo(I->getOperand(i+1)->getType()))
           return false;   // Operands must have compatible types!
 
       // Okay, at this point, we know that all of the arguments can be
@@ -878,7 +875,7 @@
     const FunctionType *FTy = cast<FunctionType>(MPtr->getElementType());
     if (!FTy->isVarArg()) return false;
 
-    if ((OpNum-1) < FTy->getParamTypes().size())
+    if ((OpNum-1) < FTy->getNumParams())
       return false;  // It's not in the varargs section...
 
     // If we get this far, we know the value is in the varargs section of the
@@ -1175,7 +1172,6 @@
     if (Meth == OldVal) {   // Changing the function pointer?
       const PointerType *NewPTy = cast<PointerType>(NewVal->getType());
       const FunctionType *NewTy = cast<FunctionType>(NewPTy->getElementType());
-      const FunctionType::ParamTypes &PTs = NewTy->getParamTypes();
 
       if (NewTy->getReturnType() == Type::VoidTy)
         Name = "";  // Make sure not to name a void call!
@@ -1191,12 +1187,13 @@
       // Convert over all of the call operands to their new types... but only
       // convert over the part that is not in the vararg section of the call.
       //
-      for (unsigned i = 0; i < PTs.size(); ++i)
-        if (Params[i]->getType() != PTs[i]) {
+      for (unsigned i = 0; i != NewTy->getNumParams(); ++i)
+        if (Params[i]->getType() != NewTy->getParamType(i)) {
           // Create a cast to convert it to the right type, we know that this
           // is a lossless cast...
           //
-          Params[i] = new CastInst(Params[i], PTs[i],  "callarg.cast." +
+          Params[i] = new CastInst(Params[i], NewTy->getParamType(i),
+                                   "callarg.cast." +
                                    Params[i]->getName(), It);
         }
       Meth = NewVal;  // Update call destination to new value
diff --git a/llvm/lib/Transforms/IPO/FunctionResolution.cpp b/llvm/lib/Transforms/IPO/FunctionResolution.cpp
index 8361930..d017980 100644
--- a/llvm/lib/Transforms/IPO/FunctionResolution.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionResolution.cpp
@@ -58,7 +58,7 @@
       const FunctionType *OldMT = Old->getFunctionType();
       const FunctionType *ConcreteMT = Concrete->getFunctionType();
       
-      if (OldMT->getParamTypes().size() > ConcreteMT->getParamTypes().size() &&
+      if (OldMT->getNumParams() > ConcreteMT->getNumParams() &&
           !ConcreteMT->isVarArg())
         if (!Old->use_empty()) {
           std::cerr << "WARNING: Linking function '" << Old->getName()
@@ -73,14 +73,14 @@
       // Check to make sure that if there are specified types, that they
       // match...
       //
-      unsigned NumArguments = std::min(OldMT->getParamTypes().size(),
-                                       ConcreteMT->getParamTypes().size());
+      unsigned NumArguments = std::min(OldMT->getNumParams(),
+                                       ConcreteMT->getNumParams());
 
       if (!Old->use_empty() && !Concrete->use_empty())
         for (unsigned i = 0; i < NumArguments; ++i)
-          if (OldMT->getParamTypes()[i] != ConcreteMT->getParamTypes()[i])
-            if (OldMT->getParamTypes()[i]->getPrimitiveID() != 
-                ConcreteMT->getParamTypes()[i]->getPrimitiveID()) {
+          if (OldMT->getParamType(i) != ConcreteMT->getParamType(i))
+            if (OldMT->getParamType(i)->getPrimitiveID() != 
+                ConcreteMT->getParamType(i)->getPrimitiveID()) {
               std::cerr << "WARNING: Function [" << Old->getName()
                         << "]: Parameter types conflict for: '";
               WriteTypeSymbolic(std::cerr, OldMT, &M);
@@ -231,7 +231,7 @@
           if ((ConcreteF->getReturnType() == OtherF->getReturnType() ||
                CallersAllIgnoreReturnValue(*OtherF)) &&
               OtherF->getFunctionType()->isVarArg() &&
-              OtherF->getFunctionType()->getParamTypes().empty())
+              OtherF->getFunctionType()->getNumParams() == 0)
             DontPrintWarning = true;
       
       // Otherwise, if the non-concrete global is a global array variable with a
diff --git a/llvm/lib/Transforms/IPO/MutateStructTypes.cpp b/llvm/lib/Transforms/IPO/MutateStructTypes.cpp
index e2c362f..d5bf4c3 100644
--- a/llvm/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/llvm/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -60,8 +60,8 @@
     const Type *RetTy = ConvertType(FT->getReturnType());
     std::vector<const Type*> ArgTypes;
 
-    for (FunctionType::ParamTypes::const_iterator I = FT->getParamTypes().begin(),
-           E = FT->getParamTypes().end(); I != E; ++I)
+    for (FunctionType::param_iterator I = FT->param_begin(),
+           E = FT->param_end(); I != E; ++I)
       ArgTypes.push_back(ConvertType(*I));
     
     DestTy = FunctionType::get(RetTy, ArgTypes, FT->isVarArg());