Start using the new and improve interface to FunctionType arguments
authorChris Lattner <sabre@nondot.org>
Mon, 9 Feb 2004 04:14:01 +0000 (04:14 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 9 Feb 2004 04:14:01 +0000 (04:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11224 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
lib/AsmParser/llvmAsmParser.y
lib/Bytecode/Reader/InstructionReader.cpp
lib/Bytecode/Reader/Reader.cpp
lib/Bytecode/Writer/ConstantWriter.cpp
lib/ExecutionEngine/Interpreter/Interpreter.cpp
lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp
lib/Transforms/ExprTypeConvert.cpp
lib/Transforms/IPO/FunctionResolution.cpp
lib/Transforms/IPO/MutateStructTypes.cpp
lib/VMCore/AsmWriter.cpp
lib/VMCore/Type.cpp
lib/VMCore/iCall.cpp

index 6eb9a46456bcc9456b4b83796dabbcebfdcd0ca5..0981eabd82ed7d5c68b146dfd9de54b8762baba5 100644 (file)
@@ -1668,8 +1668,8 @@ BBTerminatorInst : RET ResolvedVal {              // Return with a result...
       // Loop through FunctionType's arguments and ensure they are specified
       // correctly!
       //
-      FunctionType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
-      FunctionType::ParamTypes::const_iterator E = Ty->getParamTypes().end();
+      FunctionType::param_iterator I = Ty->param_begin();
+      FunctionType::param_iterator E = Ty->param_end();
       std::vector<Value*>::iterator ArgI = $5->begin(), ArgE = $5->end();
 
       for (; ArgI != ArgE && I != E; ++ArgI, ++I)
@@ -1869,8 +1869,8 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
       // Loop through FunctionType's arguments and ensure they are specified
       // correctly!
       //
-      FunctionType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
-      FunctionType::ParamTypes::const_iterator E = Ty->getParamTypes().end();
+      FunctionType::param_iterator I = Ty->param_begin();
+      FunctionType::param_iterator E = Ty->param_end();
       std::vector<Value*>::iterator ArgI = $5->begin(), ArgE = $5->end();
 
       for (; ArgI != ArgE && I != E; ++ArgI, ++I)
index 21a1490397afb7e94e3b8ea3ae5188863fb5e2ed..8912704c6f624d59bb4b2b4ff0c88580eefcf085 100644 (file)
@@ -218,16 +218,16 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf,
     if (FTy == 0) throw std::string("Call to non function pointer value!");
 
     std::vector<Value *> Params;
-    const FunctionType::ParamTypes &PL = FTy->getParamTypes();
-
     if (!FTy->isVarArg()) {
-      FunctionType::ParamTypes::const_iterator It = PL.begin();
+      FunctionType::param_iterator It = FTy->param_begin();
 
       for (unsigned i = 1, e = Args.size(); i != e; ++i) {
-        if (It == PL.end()) throw std::string("Invalid call instruction!");
+        if (It == FTy->param_end())
+          throw std::string("Invalid call instruction!");
         Params.push_back(getValue(getTypeSlot(*It++), Args[i]));
       }
-      if (It != PL.end()) throw std::string("Invalid call instruction!");
+      if (It != FTy->param_end())
+        throw std::string("Invalid call instruction!");
     } else {
       Args.erase(Args.begin(), Args.begin()+1+hasVarArgCallPadding);
 
@@ -268,18 +268,18 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf,
     std::vector<Value *> Params;
     BasicBlock *Normal, *Except;
 
-    const FunctionType::ParamTypes &PL = FTy->getParamTypes();
-
     if (!FTy->isVarArg()) {
       Normal = getBasicBlock(Args[1]);
       Except = getBasicBlock(Args[2]);
 
-      FunctionType::ParamTypes::const_iterator It = PL.begin();
+      FunctionType::param_iterator It = FTy->param_begin();
       for (unsigned i = 3, e = Args.size(); i != e; ++i) {
-        if (It == PL.end()) throw std::string("Invalid invoke instruction!");
+        if (It == FTy->param_end())
+          throw std::string("Invalid invoke instruction!");
         Params.push_back(getValue(getTypeSlot(*It++), Args[i]));
       }
-      if (It != PL.end()) throw std::string("Invalid invoke instruction!");
+      if (It != FTy->param_end())
+        throw std::string("Invalid invoke instruction!");
     } else {
       Args.erase(Args.begin(), Args.begin()+1+hasVarArgCallPadding);
 
index 977acbc861ba8e4daf378466c821572a7e854cff..4a3a5c66d723f8c91b1d5920647c5a7b7856cb18 100644 (file)
@@ -381,11 +381,10 @@ void BytecodeParser::materializeFunction(Function* F) {
         // Insert arguments into the value table before we parse the first basic
         // block in the function, but after we potentially read in the
         // compaction table.
-        const FunctionType::ParamTypes &Params =
-          F->getFunctionType()->getParamTypes();
+        const FunctionType *FT = F->getFunctionType();
         Function::aiterator AI = F->abegin();
-        for (FunctionType::ParamTypes::const_iterator It = Params.begin();
-             It != Params.end(); ++It, ++AI)
+        for (FunctionType::param_iterator It = FT->param_begin();
+             It != FT->param_end(); ++It, ++AI)
           insertValue(AI, getTypeSlot(AI->getType()), Values);
         InsertedArguments = true;
       }
@@ -404,11 +403,10 @@ void BytecodeParser::materializeFunction(Function* F) {
         // Insert arguments into the value table before we parse the first basic
         // block in the function, but after we potentially read in the
         // compaction table.
-        const FunctionType::ParamTypes &Params =
-          F->getFunctionType()->getParamTypes();
+        const FunctionType *FT = F->getFunctionType();
         Function::aiterator AI = F->abegin();
-        for (FunctionType::ParamTypes::const_iterator It = Params.begin();
-             It != Params.end(); ++It, ++AI)
+        for (FunctionType::param_iterator It = FT->param_begin();
+             It != FT->param_end(); ++It, ++AI)
           insertValue(AI, getTypeSlot(AI->getType()), Values);
         InsertedArguments = true;
       }
@@ -424,11 +422,10 @@ void BytecodeParser::materializeFunction(Function* F) {
       // list for the function, but after we potentially read in the compaction
       // table.
       if (!InsertedArguments) {
-        const FunctionType::ParamTypes &Params =
-          F->getFunctionType()->getParamTypes();
+        const FunctionType *FT = F->getFunctionType();
         Function::aiterator AI = F->abegin();
-        for (FunctionType::ParamTypes::const_iterator It = Params.begin();
-             It != Params.end(); ++It, ++AI)
+        for (FunctionType::param_iterator It = FT->param_begin();
+             It != FT->param_end(); ++It, ++AI)
           insertValue(AI, getTypeSlot(AI->getType()), Values);
         InsertedArguments = true;
       }
index 6fe596872ea0bb1da2ac99c2d4f94e95c5e9d65d..6d49165b028f847ff76f40cff2699c2fb2121da0 100644 (file)
@@ -34,12 +34,12 @@ void BytecodeWriter::outputType(const Type *T) {
     assert(Slot != -1 && "Type used but not available!!");
     output_vbr((unsigned)Slot, Out);
 
-    // Output the number of arguments to method (+1 if varargs):
-    output_vbr((unsigned)MT->getParamTypes().size()+MT->isVarArg(), Out);
+    // Output the number of arguments to function (+1 if varargs):
+    output_vbr((unsigned)MT->getNumParams()+MT->isVarArg(), Out);
 
     // Output all of the arguments...
-    FunctionType::ParamTypes::const_iterator I = MT->getParamTypes().begin();
-    for (; I != MT->getParamTypes().end(); ++I) {
+    FunctionType::param_iterator I = MT->param_begin();
+    for (; I != MT->param_end(); ++I) {
       Slot = Table.getSlot(*I);
       assert(Slot != -1 && "Type used but not available!!");
       output_vbr((unsigned)Slot, Out);
index 46e5ef0b6ac30ef8591216df20358e2b339d28f2..9780add37d3a8dadc57dbbdd7d9baef05e1eb6e5 100644 (file)
@@ -89,9 +89,9 @@ GenericValue Interpreter::runFunction(Function *F,
   // take into account gratuitous differences in declared types,
   // though.
   std::vector<GenericValue> ActualArgs;
-  const unsigned ArgCount = F->getFunctionType()->getParamTypes().size();
+  const unsigned ArgCount = F->getFunctionType()->getNumParams();
   for (unsigned i = 0; i < ArgCount; ++i)
-    ActualArgs.push_back (ArgValues[i]);
+    ActualArgs.push_back(ArgValues[i]);
   
   // Set up the function call.
   callFunction(F, ActualArgs);
index 7e1c84f7d1fad8d33d79d89cd189f4ea229e3811..a4b7d8f4dba7346ad09b843ac74cfa57aa3d6f27 100644 (file)
@@ -201,17 +201,16 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
     const FunctionType *MTy = cast<FunctionType>(Ty);
     std::stringstream FunctionInnards; 
     FunctionInnards << " (" << NameSoFar << ") (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = MTy->getParamTypes().begin(),
-           E = MTy->getParamTypes().end(); I != E; ++I) {
-      if (I != MTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = MTy->param_begin(),
+           E = MTy->param_end(); I != E; ++I) {
+      if (I != MTy->param_begin())
         FunctionInnards << ", ";
       printType(FunctionInnards, *I, "");
     }
     if (MTy->isVarArg()) {
-      if (!MTy->getParamTypes().empty()) 
+      if (MTy->getNumParams()) 
        FunctionInnards << ", ...";
-    } else if (MTy->getParamTypes().empty()) {
+    } else if (!MTy->getNumParams()) {
       FunctionInnards << "void";
     }
     FunctionInnards << ")";
@@ -948,10 +947,9 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
     }
   } else {
     // Loop over the arguments, printing them...
-    for (FunctionType::ParamTypes::const_iterator I = 
-          FT->getParamTypes().begin(),
-          E = FT->getParamTypes().end(); I != E; ++I) {
-      if (I != FT->getParamTypes().begin()) FunctionInnards << ", ";
+    for (FunctionType::param_iterator I = FT->param_begin(),
+          E = FT->param_end(); I != E; ++I) {
+      if (I != FT->param_begin()) FunctionInnards << ", ";
       printType(FunctionInnards, *I);
     }
   }
@@ -959,10 +957,10 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
   // Finish printing arguments... if this is a vararg function, print the ...,
   // unless there are no known types, in which case, we just emit ().
   //
-  if (FT->isVarArg() && !FT->getParamTypes().empty()) {
-    if (FT->getParamTypes().size()) FunctionInnards << ", ";
+  if (FT->isVarArg() && FT->getNumParams()) {
+    if (FT->getNumParams()) FunctionInnards << ", ";
     FunctionInnards << "...";  // Output varargs portion of signature!
-  } else if (!FT->isVarArg() && FT->getParamTypes().empty()) {
+  } else if (!FT->isVarArg() && FT->getNumParams() == 0) {
     FunctionInnards << "void"; // ret() -> ret(void) in C.
   }
   FunctionInnards << ")";
index 7e1c84f7d1fad8d33d79d89cd189f4ea229e3811..a4b7d8f4dba7346ad09b843ac74cfa57aa3d6f27 100644 (file)
@@ -201,17 +201,16 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
     const FunctionType *MTy = cast<FunctionType>(Ty);
     std::stringstream FunctionInnards; 
     FunctionInnards << " (" << NameSoFar << ") (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = MTy->getParamTypes().begin(),
-           E = MTy->getParamTypes().end(); I != E; ++I) {
-      if (I != MTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = MTy->param_begin(),
+           E = MTy->param_end(); I != E; ++I) {
+      if (I != MTy->param_begin())
         FunctionInnards << ", ";
       printType(FunctionInnards, *I, "");
     }
     if (MTy->isVarArg()) {
-      if (!MTy->getParamTypes().empty()) 
+      if (MTy->getNumParams()) 
        FunctionInnards << ", ...";
-    } else if (MTy->getParamTypes().empty()) {
+    } else if (!MTy->getNumParams()) {
       FunctionInnards << "void";
     }
     FunctionInnards << ")";
@@ -948,10 +947,9 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
     }
   } else {
     // Loop over the arguments, printing them...
-    for (FunctionType::ParamTypes::const_iterator I = 
-          FT->getParamTypes().begin(),
-          E = FT->getParamTypes().end(); I != E; ++I) {
-      if (I != FT->getParamTypes().begin()) FunctionInnards << ", ";
+    for (FunctionType::param_iterator I = FT->param_begin(),
+          E = FT->param_end(); I != E; ++I) {
+      if (I != FT->param_begin()) FunctionInnards << ", ";
       printType(FunctionInnards, *I);
     }
   }
@@ -959,10 +957,10 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
   // Finish printing arguments... if this is a vararg function, print the ...,
   // unless there are no known types, in which case, we just emit ().
   //
-  if (FT->isVarArg() && !FT->getParamTypes().empty()) {
-    if (FT->getParamTypes().size()) FunctionInnards << ", ";
+  if (FT->isVarArg() && FT->getNumParams()) {
+    if (FT->getNumParams()) FunctionInnards << ", ";
     FunctionInnards << "...";  // Output varargs portion of signature!
-  } else if (!FT->isVarArg() && FT->getParamTypes().empty()) {
+  } else if (!FT->isVarArg() && FT->getNumParams() == 0) {
     FunctionInnards << "void"; // ret() -> ret(void) in C.
   }
   FunctionInnards << ")";
index d46878d26b6b0894ff6968c2f0099cb685e734cd..9fc9c93d4bfc09ae28fc6878edf04b73544f8594 100644 (file)
@@ -304,8 +304,7 @@ bool llvm::ExpressionConvertibleToType(Value *V, const Type *Ty,
     //
     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 @@ Value *llvm::ConvertExpressionToType(Value *V, const Type *Ty,
     //
     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 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
       // 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 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
     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 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
     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 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
       // 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
index 8361930e94437f6504edcada7213887eab6b6caa..d0179809b98d9a7beb19b28769180a39811f174c 100644 (file)
@@ -58,7 +58,7 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals,
       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 @@ static bool ResolveFunctions(Module &M, std::vector<GlobalValue*> &Globals,
       // 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 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
           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
index e2c362f3ab244cba7b74fdfc29e99c6f962a61b6..d5bf4c3bfa790a3bf49151eaa6582905d14b9170 100644 (file)
@@ -60,8 +60,8 @@ const Type *MutateStructTypes::ConvertType(const Type *Ty) {
     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());
index 32cc4c72f0c2cf0fbb395fa229ed2398251fd148..3ed2312f78f17aa7fa5edd5ec439bdab11e95396 100644 (file)
@@ -153,15 +153,14 @@ static std::string calcTypeName(const Type *Ty,
   case Type::FunctionTyID: {
     const FunctionType *FTy = cast<FunctionType>(Ty);
     Result = calcTypeName(FTy->getReturnType(), TypeStack, TypeNames) + " (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = FTy->getParamTypes().begin(),
-           E = FTy->getParamTypes().end(); I != E; ++I) {
-      if (I != FTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = FTy->param_begin(),
+           E = FTy->param_end(); I != E; ++I) {
+      if (I != FTy->param_begin())
         Result += ", ";
       Result += calcTypeName(*I, TypeStack, TypeNames);
     }
     if (FTy->isVarArg()) {
-      if (!FTy->getParamTypes().empty()) Result += ", ";
+      if (FTy->getNumParams()) Result += ", ";
       Result += "...";
     }
     Result += ")";
@@ -517,15 +516,14 @@ private :
 std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
   if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
     printType(FTy->getReturnType()) << " (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = FTy->getParamTypes().begin(),
-           E = FTy->getParamTypes().end(); I != E; ++I) {
-      if (I != FTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = FTy->param_begin(),
+           E = FTy->param_end(); I != E; ++I) {
+      if (I != FTy->param_begin())
         Out << ", ";
       printType(*I);
     }
     if (FTy->isVarArg()) {
-      if (!FTy->getParamTypes().empty()) Out << ", ";
+      if (FTy->getNumParams()) Out << ", ";
       Out << "...";
     }
     Out << ")";
@@ -689,7 +687,7 @@ void AssemblyWriter::printFunction(const Function *F) {
 
   // Finish printing arguments...
   if (FT->isVarArg()) {
-    if (FT->getParamTypes().size()) Out << ", ";
+    if (FT->getNumParams()) Out << ", ";
     Out << "...";  // Output varargs portion of signature!
   }
   Out << ")";
index 1fd65f4dc02e1dbabaa3b6a852c9edccd0a9bedf..77389550eedaf415bfe0bb37d5f1afd3844d98e1 100644 (file)
@@ -190,15 +190,14 @@ static std::string getTypeDescription(const Type *Ty,
   case Type::FunctionTyID: {
     const FunctionType *FTy = cast<FunctionType>(Ty);
     Result = getTypeDescription(FTy->getReturnType(), TypeStack) + " (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = FTy->getParamTypes().begin(),
-           E = FTy->getParamTypes().end(); I != E; ++I) {
-      if (I != FTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = FTy->param_begin(),
+           E = FTy->param_end(); I != E; ++I) {
+      if (I != FTy->param_begin())
         Result += ", ";
       Result += getTypeDescription(*I, TypeStack);
     }
     if (FTy->isVarArg()) {
-      if (!FTy->getParamTypes().empty()) Result += ", ";
+      if (FTy->getNumParams()) Result += ", ";
       Result += "...";
     }
     Result += ")";
@@ -528,13 +527,11 @@ static bool TypesEqual(const Type *Ty, const Type *Ty2,
   } else if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
     const FunctionType *FTy2 = cast<FunctionType>(Ty2);
     if (FTy->isVarArg() != FTy2->isVarArg() ||
-        FTy->getParamTypes().size() != FTy2->getParamTypes().size() ||
+        FTy->getNumParams() != FTy2->getNumParams() ||
         !TypesEqual(FTy->getReturnType(), FTy2->getReturnType(), EqTypes))
       return false;
-    const FunctionType::ParamTypes &FTyP = FTy->getParamTypes();
-    const FunctionType::ParamTypes &FTy2P = FTy2->getParamTypes();
-    for (unsigned i = 0, e = FTyP.size(); i != e; ++i)
-      if (!TypesEqual(FTyP[i], FTy2P[i], EqTypes))
+    for (unsigned i = 0, e = FTy2->getNumParams(); i != e; ++i)
+      if (!TypesEqual(FTy->getParamType(i), FTy2->getParamType(i), EqTypes))
         return false;
     return true;
   } else {
@@ -736,8 +733,8 @@ static TypeMap<FunctionValType, FunctionType> FunctionTypes;
 FunctionValType FunctionValType::get(const FunctionType *FT) {
   // Build up a FunctionValType
   std::vector<const Type *> ParamTypes;
-  ParamTypes.reserve(FT->getParamTypes().size());
-  for (unsigned i = 0, e = FT->getParamTypes().size(); i != e; ++i)
+  ParamTypes.reserve(FT->getNumParams());
+  for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
     ParamTypes.push_back(FT->getParamType(i));
   return FunctionValType(FT->getReturnType(), ParamTypes, FT->isVarArg());
 }
index 2d41dcd274349a54c283b08016ce34ad08afd02f..37298f99fd49e406962559c467d2a85d1c6731c7 100644 (file)
@@ -31,14 +31,13 @@ CallInst::CallInst(Value *Func, const std::vector<Value*> &params,
   Operands.reserve(1+params.size());
   Operands.push_back(Use(Func, this));
 
-  const FunctionType *MTy = 
+  const FunctionType *FTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
 
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert(params.size() == PL.size() || 
-        (MTy->isVarArg() && params.size() > PL.size()) &&
+  assert((params.size() == FTy->getNumParams() || 
+          (FTy->isVarArg() && params.size() > FTy->getNumParams())) &&
         "Calling a function with bad signature");
-  for (unsigned i = 0; i < params.size(); i++)
+  for (unsigned i = 0; i != params.size(); i++)
     Operands.push_back(Use(params[i], this));
 }
 
@@ -53,8 +52,7 @@ CallInst::CallInst(Value *Func, const std::string &Name,
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
 
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert(PL.empty() && "Calling a function with bad signature");
+  assert(MTy->getNumParams() == 0 && "Calling a function with bad signature");
 }
 
 CallInst::CallInst(Value *Func, Value* A, const std::string &Name,
@@ -68,8 +66,8 @@ CallInst::CallInst(Value *Func, Value* A, const std::string &Name,
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
 
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert(PL.size() == 1 || (MTy->isVarArg() && PL.empty()) &&
+  assert((MTy->getNumParams() == 1 ||
+          (MTy->isVarArg() && MTy->getNumParams() == 0)) &&
         "Calling a function with bad signature");
   Operands.push_back(Use(A, this));
 }
@@ -115,9 +113,8 @@ InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal,
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
   
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert((params.size() == PL.size()) || 
-        (MTy->isVarArg() && params.size() > PL.size()) &&
+  assert((params.size() == MTy->getNumParams()) || 
+        (MTy->isVarArg() && params.size() > MTy->getNumParams()) &&
         "Calling a function with bad signature");
   
   for (unsigned i = 0; i < params.size(); i++)
@@ -138,9 +135,8 @@ InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal,
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
   
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert((params.size() == PL.size()) || 
-        (MTy->isVarArg() && params.size() > PL.size()) &&
+  assert((params.size() == MTy->getNumParams()) || 
+        (MTy->isVarArg() && params.size() > MTy->getNumParams()) &&
         "Calling a function with bad signature");
   
   for (unsigned i = 0; i < params.size(); i++)