@@ -225,12 +225,11 @@ void CodeGenFunction::StartThunk(llvm::Function *Fn, GlobalDecl GD,
225225 CXXThisValue = CXXABIThisValue;
226226}
227227
228- void CodeGenFunction::EmitCallAndReturnForThunk (GlobalDecl GD,
229- llvm::Value *Callee,
228+ void CodeGenFunction::EmitCallAndReturnForThunk (llvm::Value *Callee,
230229 const ThunkInfo *Thunk) {
231230 assert (isa<CXXMethodDecl>(CurGD.getDecl ()) &&
232231 " Please use a new CGF for this thunk" );
233- const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD .getDecl ());
232+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(CurGD .getDecl ());
234233
235234 // Adjust the 'this' pointer if necessary
236235 llvm::Value *AdjustedThisPtr = Thunk ? CGM.getCXXABI ().performThisAdjustment (
@@ -243,12 +242,11 @@ void CodeGenFunction::EmitCallAndReturnForThunk(GlobalDecl GD,
243242 CallArgs.add (RValue::get (AdjustedThisPtr), ThisType);
244243
245244 if (isa<CXXDestructorDecl>(MD))
246- CGM.getCXXABI ().adjustCallArgsForDestructorThunk (*this , GD , CallArgs);
245+ CGM.getCXXABI ().adjustCallArgsForDestructorThunk (*this , CurGD , CallArgs);
247246
248247 // Add the rest of the arguments.
249- for (FunctionDecl::param_const_iterator I = MD->param_begin (),
250- E = MD->param_end (); I != E; ++I)
251- EmitDelegateCallArg (CallArgs, *I, (*I)->getLocStart ());
248+ for (const ParmVarDecl *PD : MD->params ())
249+ EmitDelegateCallArg (CallArgs, PD, PD->getLocStart ());
252250
253251 const FunctionProtoType *FPT = MD->getType ()->getAs <FunctionProtoType>();
254252
@@ -272,7 +270,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(GlobalDecl GD,
272270
273271 // Determine whether we have a return value slot to use.
274272 QualType ResultType =
275- CGM.getCXXABI ().HasThisReturn (GD ) ? ThisType : FPT->getReturnType ();
273+ CGM.getCXXABI ().HasThisReturn (CurGD ) ? ThisType : FPT->getReturnType ();
276274 ReturnValueSlot Slot;
277275 if (!ResultType->isVoidType () &&
278276 CurFnInfo->getReturnInfo ().getKind () == ABIArgInfo::Indirect &&
@@ -307,7 +305,7 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn,
307305 llvm::Value *Callee = CGM.GetAddrOfFunction (GD, Ty, /* ForVTable=*/ true );
308306
309307 // Make the call and return the result.
310- EmitCallAndReturnForThunk (GD, Callee, &Thunk);
308+ EmitCallAndReturnForThunk (Callee, &Thunk);
311309
312310 // Set the right linkage.
313311 CGM.setFunctionLinkage (GD, Fn);
0 commit comments