From: Chris Lattner Date: Mon, 9 Feb 2004 04:14:01 +0000 (+0000) Subject: Start using the new and improve interface to FunctionType arguments X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=d5d89967206e1153d24abdb7b22002f7533f55c7 Start using the new and improve interface to FunctionType arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11224 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 6eb9a46456b..0981eabd82e 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -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::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::iterator ArgI = $5->begin(), ArgE = $5->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index 21a1490397a..8912704c6f6 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -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 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 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); diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 977acbc861b..4a3a5c66d72 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -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; } diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp index 6fe596872ea..6d49165b028 100644 --- a/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/lib/Bytecode/Writer/ConstantWriter.cpp @@ -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); diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp index 46e5ef0b6ac..9780add37d3 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -89,9 +89,9 @@ GenericValue Interpreter::runFunction(Function *F, // take into account gratuitous differences in declared types, // though. std::vector 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); diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 7e1c84f7d1f..a4b7d8f4dba 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -201,17 +201,16 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty, const FunctionType *MTy = cast(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 << ")"; diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 7e1c84f7d1f..a4b7d8f4dba 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -201,17 +201,16 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty, const FunctionType *MTy = cast(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 << ")"; diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index d46878d26b6..9fc9c93d4bf 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -304,8 +304,7 @@ bool llvm::ExpressionConvertibleToType(Value *V, const Type *Ty, // const PointerType *PT = cast(I->getOperand(0)->getType()); const FunctionType *FT = cast(PT->getElementType()); - std::vector ArgTys(FT->getParamTypes().begin(), - FT->getParamTypes().end()); + std::vector 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(I->getOperand(0)->getType()); const FunctionType *FT = cast(PT->getElementType()); - std::vector ArgTys(FT->getParamTypes().begin(), - FT->getParamTypes().end()); + std::vector 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(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(NewVal->getType()); const FunctionType *NewTy = cast(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 diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index 8361930e944..d0179809b98 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -58,7 +58,7 @@ static bool ResolveFunctions(Module &M, std::vector &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 &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 diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index e2c362f3ab2..d5bf4c3bfa7 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -60,8 +60,8 @@ const Type *MutateStructTypes::ConvertType(const Type *Ty) { const Type *RetTy = ConvertType(FT->getReturnType()); std::vector 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()); diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 32cc4c72f0c..3ed2312f78f 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -153,15 +153,14 @@ static std::string calcTypeName(const Type *Ty, case Type::FunctionTyID: { const FunctionType *FTy = cast(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(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 << ")"; diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 1fd65f4dc02..77389550eed 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -190,15 +190,14 @@ static std::string getTypeDescription(const Type *Ty, case Type::FunctionTyID: { const FunctionType *FTy = cast(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(Ty)) { const FunctionType *FTy2 = cast(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 FunctionTypes; FunctionValType FunctionValType::get(const FunctionType *FT) { // Build up a FunctionValType std::vector 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()); } diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp index 2d41dcd2743..37298f99fd4 100644 --- a/lib/VMCore/iCall.cpp +++ b/lib/VMCore/iCall.cpp @@ -31,14 +31,13 @@ CallInst::CallInst(Value *Func, const std::vector ¶ms, Operands.reserve(1+params.size()); Operands.push_back(Use(Func, this)); - const FunctionType *MTy = + const FunctionType *FTy = cast(cast(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(cast(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(cast(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(cast(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(cast(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++)