From 04c9a49ee251424b11d7c4e8b1c23637684cecb6 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 2 May 2011 17:57:46 +0000 Subject: [PATCH] Simplify code a bit by using CallArgList::add. No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130699 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBlocks.cpp | 2 +- lib/CodeGen/CGClass.cpp | 10 +++---- lib/CodeGen/CGDecl.cpp | 4 +-- lib/CodeGen/CGExprCXX.cpp | 29 +++++++++--------- lib/CodeGen/CGObjC.cpp | 62 ++++++++++++++++----------------------- lib/CodeGen/CGObjCGNU.cpp | 13 +++----- lib/CodeGen/CGObjCMac.cpp | 10 +++---- lib/CodeGen/CGVTables.cpp | 2 +- 8 files changed, 55 insertions(+), 77 deletions(-) diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 8d9c032f5f..99a69a4f4a 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -722,7 +722,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E, // Add the block literal. QualType VoidPtrTy = getContext().getPointerType(getContext().VoidTy); CallArgList Args; - Args.push_back(std::make_pair(RValue::get(BlockLiteral), VoidPtrTy)); + Args.add(RValue::get(BlockLiteral), VoidPtrTy); QualType FnType = BPT->getPointeeType(); diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 1227b4c1b2..ca8b6576c7 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -1199,15 +1199,14 @@ CodeGenFunction::EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, CallArgList Args; // Push the this ptr. - Args.push_back(std::make_pair(RValue::get(This), - D->getThisType(getContext()))); + Args.add(RValue::get(This), D->getThisType(getContext())); // Push the src ptr. QualType QT = *(FPT->arg_type_begin()); const llvm::Type *t = CGM.getTypes().ConvertType(QT); Src = Builder.CreateBitCast(Src, t); - Args.push_back(std::make_pair(RValue::get(Src), QT)); + Args.add(RValue::get(Src), QT); // Skip over first argument (Src). ++ArgBeg; @@ -1243,15 +1242,14 @@ CodeGenFunction::EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor, assert(I != E && "no parameters to constructor"); // this - DelegateArgs.push_back(std::make_pair(RValue::get(LoadCXXThis()), - (*I)->getType())); + DelegateArgs.add(RValue::get(LoadCXXThis()), (*I)->getType()); ++I; // vtt if (llvm::Value *VTT = GetVTTParameter(*this, GlobalDecl(Ctor, CtorType), /*ForVirtualBase=*/false)) { QualType VoidPP = getContext().getPointerType(getContext().VoidPtrTy); - DelegateArgs.push_back(std::make_pair(RValue::get(VTT), VoidPP)); + DelegateArgs.add(RValue::get(VTT), VoidPP); if (CodeGenVTables::needsVTTParameter(CurGD)) { assert(I != E && "cannot skip vtt parameter, already done with args"); diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index d496982b81..c027375818 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -392,8 +392,8 @@ namespace { CGF.Builder.CreateBitCast(Addr, CGF.ConvertType(ArgTy)); CallArgList Args; - Args.push_back(std::make_pair(RValue::get(Arg), - CGF.getContext().getPointerType(Var.getType()))); + Args.add(RValue::get(Arg), + CGF.getContext().getPointerType(Var.getType())); CGF.EmitCall(FnInfo, CleanupFn, ReturnValueSlot(), Args); } }; diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index e66afc6290..7933007186 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -37,13 +37,12 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD, CallArgList Args; // Push the this ptr. - Args.push_back(std::make_pair(RValue::get(This), - MD->getThisType(getContext()))); + Args.add(RValue::get(This), MD->getThisType(getContext())); // If there is a VTT parameter, emit it. if (VTT) { QualType T = getContext().getPointerType(getContext().VoidPtrTy); - Args.push_back(std::make_pair(RValue::get(VTT), T)); + Args.add(RValue::get(VTT), T); } // And the rest of the call args @@ -317,7 +316,7 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, getContext().getPointerType(getContext().getTagDeclType(RD)); // Push the this ptr. - Args.push_back(std::make_pair(RValue::get(This), ThisType)); + Args.add(RValue::get(This), ThisType); // And the rest of the call args EmitCallArgs(Args, FPT, E->arg_begin(), E->arg_end()); @@ -837,15 +836,15 @@ namespace { // The first argument is always a void*. FunctionProtoType::arg_type_iterator AI = FPT->arg_type_begin(); - DeleteArgs.push_back(std::make_pair(RValue::get(Ptr), *AI++)); + DeleteArgs.add(RValue::get(Ptr), *AI++); // A member 'operator delete' can take an extra 'size_t' argument. if (FPT->getNumArgs() == NumPlacementArgs + 2) - DeleteArgs.push_back(std::make_pair(RValue::get(AllocSize), *AI++)); + DeleteArgs.add(RValue::get(AllocSize), *AI++); // Pass the rest of the arguments, which must match exactly. for (unsigned I = 0; I != NumPlacementArgs; ++I) - DeleteArgs.push_back(std::make_pair(getPlacementArgs()[I], *AI++)); + DeleteArgs.add(getPlacementArgs()[I], *AI++); // Call 'operator delete'. CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT), @@ -894,18 +893,18 @@ namespace { // The first argument is always a void*. FunctionProtoType::arg_type_iterator AI = FPT->arg_type_begin(); - DeleteArgs.push_back(std::make_pair(Ptr.restore(CGF), *AI++)); + DeleteArgs.add(Ptr.restore(CGF), *AI++); // A member 'operator delete' can take an extra 'size_t' argument. if (FPT->getNumArgs() == NumPlacementArgs + 2) { RValue RV = AllocSize.restore(CGF); - DeleteArgs.push_back(std::make_pair(RV, *AI++)); + DeleteArgs.add(RV, *AI++); } // Pass the rest of the arguments, which must match exactly. for (unsigned I = 0; I != NumPlacementArgs; ++I) { RValue RV = getPlacementArgs()[I].restore(CGF); - DeleteArgs.push_back(std::make_pair(RV, *AI++)); + DeleteArgs.add(RV, *AI++); } // Call 'operator delete'. @@ -976,7 +975,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) { EmitCXXNewAllocSize(getContext(), *this, E, numElements, allocSizeWithoutCookie); - allocatorArgs.push_back(std::make_pair(RValue::get(allocSize), sizeType)); + allocatorArgs.add(RValue::get(allocSize), sizeType); // Emit the rest of the arguments. // FIXME: Ideally, this should just use EmitCallArgs. @@ -1123,10 +1122,10 @@ void CodeGenFunction::EmitDeleteCall(const FunctionDecl *DeleteFD, QualType ArgTy = DeleteFTy->getArgType(0); llvm::Value *DeletePtr = Builder.CreateBitCast(Ptr, ConvertType(ArgTy)); - DeleteArgs.push_back(std::make_pair(RValue::get(DeletePtr), ArgTy)); + DeleteArgs.add(RValue::get(DeletePtr), ArgTy); if (Size) - DeleteArgs.push_back(std::make_pair(RValue::get(Size), SizeTy)); + DeleteArgs.add(RValue::get(Size), SizeTy); // Emit the call to delete. EmitCall(CGM.getTypes().getFunctionInfo(DeleteArgs, DeleteFTy), @@ -1223,7 +1222,7 @@ namespace { QualType VoidPtrTy = DeleteFTy->getArgType(0); llvm::Value *DeletePtr = CGF.Builder.CreateBitCast(Ptr, CGF.ConvertType(VoidPtrTy)); - Args.push_back(std::make_pair(RValue::get(DeletePtr), VoidPtrTy)); + Args.add(RValue::get(DeletePtr), VoidPtrTy); // Pass the original requested size as the second argument. if (DeleteFTy->getNumArgs() == 2) { @@ -1246,7 +1245,7 @@ namespace { Size = CGF.Builder.CreateAdd(Size, CookieSizeV); } - Args.push_back(std::make_pair(RValue::get(Size), size_t)); + Args.add(RValue::get(Size), size_t); } // Emit the call to delete. diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index cfe566e6f0..5b0d41e776 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -153,27 +153,24 @@ void CodeGenFunction::GenerateObjCGetterBody(ObjCIvarDecl *Ivar, CallArgList Args; RValue RV = RValue::get(Builder.CreateBitCast(ReturnValue, Types.ConvertType(getContext().VoidPtrTy))); - Args.push_back(std::make_pair(RV, getContext().VoidPtrTy)); + Args.add(RV, getContext().VoidPtrTy); RV = RValue::get(Builder.CreateBitCast(LV.getAddress(), Types.ConvertType(getContext().VoidPtrTy))); - Args.push_back(std::make_pair(RV, getContext().VoidPtrTy)); + Args.add(RV, getContext().VoidPtrTy); // sizeof (Type of Ivar) CharUnits Size = getContext().getTypeSizeInChars(Ivar->getType()); llvm::Value *SizeVal = llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy), Size.getQuantity()); - Args.push_back(std::make_pair(RValue::get(SizeVal), - getContext().LongTy)); + Args.add(RValue::get(SizeVal), getContext().LongTy); llvm::Value *isAtomic = llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), IsAtomic ? 1 : 0); - Args.push_back(std::make_pair(RValue::get(isAtomic), - getContext().BoolTy)); + Args.add(RValue::get(isAtomic), getContext().BoolTy); llvm::Value *hasStrong = llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), IsStrong ? 1 : 0); - Args.push_back(std::make_pair(RValue::get(hasStrong), - getContext().BoolTy)); + Args.add(RValue::get(hasStrong), getContext().BoolTy); EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args, FunctionType::ExtInfo()), GetCopyStructFn, ReturnValueSlot(), Args); @@ -234,11 +231,10 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP, llvm::Value *True = llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 1); CallArgList Args; - Args.push_back(std::make_pair(RValue::get(SelfAsId), IdTy)); - Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType())); - Args.push_back(std::make_pair(RValue::get(Offset), - getContext().getPointerDiffType())); - Args.push_back(std::make_pair(RValue::get(True), getContext().BoolTy)); + Args.add(RValue::get(SelfAsId), IdTy); + Args.add(RValue::get(CmdVal), Cmd->getType()); + Args.add(RValue::get(Offset), getContext().getPointerDiffType()); + Args.add(RValue::get(True), getContext().BoolTy); // FIXME: We shouldn't need to get the function info here, the // runtime already should have computed it to build the function. RValue RV = EmitCall(Types.getFunctionInfo(PD->getType(), Args, @@ -357,26 +353,25 @@ void CodeGenFunction::GenerateObjCAtomicSetterBody(ObjCMethodDecl *OMD, RValue RV = RValue::get(Builder.CreateBitCast(LV.getAddress(), Types.ConvertType(getContext().VoidPtrTy))); - Args.push_back(std::make_pair(RV, getContext().VoidPtrTy)); + Args.add(RV, getContext().VoidPtrTy); llvm::Value *Arg = LocalDeclMap[*OMD->param_begin()]; llvm::Value *ArgAsPtrTy = Builder.CreateBitCast(Arg, Types.ConvertType(getContext().VoidPtrTy)); RV = RValue::get(ArgAsPtrTy); - Args.push_back(std::make_pair(RV, getContext().VoidPtrTy)); + Args.add(RV, getContext().VoidPtrTy); // sizeof (Type of Ivar) CharUnits Size = getContext().getTypeSizeInChars(Ivar->getType()); llvm::Value *SizeVal = llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy), Size.getQuantity()); - Args.push_back(std::make_pair(RValue::get(SizeVal), - getContext().LongTy)); + Args.add(RValue::get(SizeVal), getContext().LongTy); llvm::Value *True = llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 1); - Args.push_back(std::make_pair(RValue::get(True), getContext().BoolTy)); + Args.add(RValue::get(True), getContext().BoolTy); llvm::Value *False = llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 0); - Args.push_back(std::make_pair(RValue::get(False), getContext().BoolTy)); + Args.add(RValue::get(False), getContext().BoolTy); EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args, FunctionType::ExtInfo()), GetCopyStructFn, ReturnValueSlot(), Args); @@ -446,15 +441,12 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP, llvm::Value *False = llvm::ConstantInt::get(Types.ConvertType(getContext().BoolTy), 0); CallArgList Args; - Args.push_back(std::make_pair(RValue::get(SelfAsId), IdTy)); - Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType())); - Args.push_back(std::make_pair(RValue::get(Offset), - getContext().getPointerDiffType())); - Args.push_back(std::make_pair(RValue::get(ArgAsId), IdTy)); - Args.push_back(std::make_pair(RValue::get(IsAtomic ? True : False), - getContext().BoolTy)); - Args.push_back(std::make_pair(RValue::get(IsCopy ? True : False), - getContext().BoolTy)); + Args.add(RValue::get(SelfAsId), IdTy); + Args.add(RValue::get(CmdVal), Cmd->getType()); + Args.add(RValue::get(Offset), getContext().getPointerDiffType()); + Args.add(RValue::get(ArgAsId), IdTy); + Args.add(RValue::get(IsAtomic ? True : False), getContext().BoolTy); + Args.add(RValue::get(IsCopy ? True : False), getContext().BoolTy); // FIXME: We shouldn't need to get the function info here, the runtime // already should have computed it to build the function. EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args, @@ -760,7 +752,7 @@ void CodeGenFunction::EmitStoreThroughPropertyRefLValue(RValue Src, } CallArgList Args; - Args.push_back(std::make_pair(Src, ArgType)); + Args.add(Src, ArgType); llvm::Value *Receiver = Dst.getPropertyRefBaseAddr(); QualType ResultType = getContext().VoidTy; @@ -832,22 +824,19 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ CallArgList Args; // The first argument is a temporary of the enumeration-state type. - Args.push_back(std::make_pair(RValue::get(StatePtr), - getContext().getPointerType(StateTy))); + Args.add(RValue::get(StatePtr), getContext().getPointerType(StateTy)); // The second argument is a temporary array with space for NumItems // pointers. We'll actually be loading elements from the array // pointer written into the control state; this buffer is so that // collections that *aren't* backed by arrays can still queue up // batches of elements. - Args.push_back(std::make_pair(RValue::get(ItemsPtr), - getContext().getPointerType(ItemsTy))); + Args.add(RValue::get(ItemsPtr), getContext().getPointerType(ItemsTy)); // The third argument is the capacity of that temporary array. const llvm::Type *UnsignedLongLTy = ConvertType(getContext().UnsignedLongTy); llvm::Constant *Count = llvm::ConstantInt::get(UnsignedLongLTy, NumItems); - Args.push_back(std::make_pair(RValue::get(Count), - getContext().UnsignedLongTy)); + Args.add(RValue::get(Count), getContext().UnsignedLongTy); // Start the enumeration. RValue CountRV = @@ -916,8 +905,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ ConvertType(getContext().getObjCIdType()), "tmp"); CallArgList Args2; - Args2.push_back(std::make_pair(RValue::get(V), - getContext().getObjCIdType())); + Args2.add(RValue::get(V), getContext().getObjCIdType()); // FIXME: We shouldn't need to get the function info here, the runtime already // should have computed it to build the function. EmitCall(CGM.getTypes().getFunctionInfo(getContext().VoidTy, Args2, diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 9ef2b98f9b..c4dc4c41da 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -960,11 +960,8 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, CallArgList ActualArgs; - ActualArgs.push_back( - std::make_pair(RValue::get(EnforceType(Builder, Receiver, IdTy)), - ASTIdTy)); - ActualArgs.push_back(std::make_pair(RValue::get(cmd), - CGF.getContext().getObjCSelType())); + ActualArgs.add(RValue::get(EnforceType(Builder, Receiver, IdTy)), ASTIdTy); + ActualArgs.add(RValue::get(cmd), CGF.getContext().getObjCSelType()); ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end()); CodeGenTypes &Types = CGM.getTypes(); @@ -1116,10 +1113,8 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF, llvm::Value *imp = LookupIMP(CGF, Receiver, cmd, node); CallArgList ActualArgs; - ActualArgs.push_back( - std::make_pair(RValue::get(Receiver), ASTIdTy)); - ActualArgs.push_back(std::make_pair(RValue::get(cmd), - CGF.getContext().getObjCSelType())); + ActualArgs.add(RValue::get(Receiver), ASTIdTy); + ActualArgs.add(RValue::get(cmd), CGF.getContext().getObjCSelType()); ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end()); CodeGenTypes &Types = CGM.getTypes(); diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 3447daf5c2..2b1cfe3da5 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1522,9 +1522,8 @@ CGObjCCommonMac::EmitLegacyMessageSend(CodeGen::CodeGenFunction &CGF, CallArgList ActualArgs; if (!IsSuper) Arg0 = CGF.Builder.CreateBitCast(Arg0, ObjCTypes.ObjectPtrTy, "tmp"); - ActualArgs.push_back(std::make_pair(RValue::get(Arg0), Arg0Ty)); - ActualArgs.push_back(std::make_pair(RValue::get(Sel), - CGF.getContext().getObjCSelType())); + ActualArgs.add(RValue::get(Arg0), Arg0Ty); + ActualArgs.add(RValue::get(Sel), CGF.getContext().getObjCSelType()); ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end()); CodeGenTypes &Types = CGM.getTypes(); @@ -5596,9 +5595,8 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend( llvm::Value *Arg1 = CGF.Builder.CreateBitCast(GV, ObjCTypes.MessageRefPtrTy); CallArgList ActualArgs; - ActualArgs.push_back(std::make_pair(RValue::get(Arg0), Arg0Ty)); - ActualArgs.push_back(std::make_pair(RValue::get(Arg1), - ObjCTypes.MessageRefCPtrTy)); + ActualArgs.add(RValue::get(Arg0), Arg0Ty); + ActualArgs.add(RValue::get(Arg1), ObjCTypes.MessageRefCPtrTy); ActualArgs.insert(ActualArgs.end(), CallArgs.begin(), CallArgs.end()); const CGFunctionInfo &FnInfo1 = Types.getFunctionInfo(ResultType, ActualArgs, FunctionType::ExtInfo()); diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 678b115753..581467c537 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -2675,7 +2675,7 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, CallArgList CallArgs; // Add our adjusted 'this' pointer. - CallArgs.push_back(std::make_pair(RValue::get(AdjustedThisPtr), ThisType)); + CallArgs.add(RValue::get(AdjustedThisPtr), ThisType); // Add the rest of the parameters. for (FunctionDecl::param_const_iterator I = MD->param_begin(),