From: Reid Kleckner Date: Sat, 26 Jul 2014 01:30:05 +0000 (+0000) Subject: Remove an extra parameter and C++11 for loop-ify this code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5b1da270c3f0fc144e6190e853d68c842c6afa1;p=clang Remove an extra parameter and C++11 for loop-ify this code git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214003 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index c53e7ed33d..ab806cc459 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -225,12 +225,11 @@ void CodeGenFunction::StartThunk(llvm::Function *Fn, GlobalDecl GD, CXXThisValue = CXXABIThisValue; } -void CodeGenFunction::EmitCallAndReturnForThunk(GlobalDecl GD, - llvm::Value *Callee, +void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk) { assert(isa(CurGD.getDecl()) && "Please use a new CGF for this thunk"); - const CXXMethodDecl *MD = cast(GD.getDecl()); + const CXXMethodDecl *MD = cast(CurGD.getDecl()); // Adjust the 'this' pointer if necessary llvm::Value *AdjustedThisPtr = Thunk ? CGM.getCXXABI().performThisAdjustment( @@ -243,12 +242,11 @@ void CodeGenFunction::EmitCallAndReturnForThunk(GlobalDecl GD, CallArgs.add(RValue::get(AdjustedThisPtr), ThisType); if (isa(MD)) - CGM.getCXXABI().adjustCallArgsForDestructorThunk(*this, GD, CallArgs); + CGM.getCXXABI().adjustCallArgsForDestructorThunk(*this, CurGD, CallArgs); // Add the rest of the arguments. - for (FunctionDecl::param_const_iterator I = MD->param_begin(), - E = MD->param_end(); I != E; ++I) - EmitDelegateCallArg(CallArgs, *I, (*I)->getLocStart()); + for (const ParmVarDecl *PD : MD->params()) + EmitDelegateCallArg(CallArgs, PD, PD->getLocStart()); const FunctionProtoType *FPT = MD->getType()->getAs(); @@ -272,7 +270,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(GlobalDecl GD, // Determine whether we have a return value slot to use. QualType ResultType = - CGM.getCXXABI().HasThisReturn(GD) ? ThisType : FPT->getReturnType(); + CGM.getCXXABI().HasThisReturn(CurGD) ? ThisType : FPT->getReturnType(); ReturnValueSlot Slot; if (!ResultType->isVoidType() && CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect && @@ -307,7 +305,7 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true); // Make the call and return the result. - EmitCallAndReturnForThunk(GD, Callee, &Thunk); + EmitCallAndReturnForThunk(Callee, &Thunk); // Set the right linkage. CGM.setFunctionLinkage(GD, Fn); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index ccf7651fdc..8dea7bd78b 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -1208,8 +1208,7 @@ public: void StartThunk(llvm::Function *Fn, GlobalDecl GD, const CGFunctionInfo &FnInfo); - void EmitCallAndReturnForThunk(GlobalDecl GD, llvm::Value *Callee, - const ThunkInfo *Thunk); + void EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk); /// GenerateThunk - Generate a thunk for the given method. void GenerateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,