Skip to content

Commit 3f76ac7

Browse files
committed
Remove an extra parameter and C++11 for loop-ify this code
llvm-svn: 214003
1 parent 6dcdaa6 commit 3f76ac7

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,7 @@ class CodeGenFunction : public CodeGenTypeCache {
12081208

12091209
void StartThunk(llvm::Function *Fn, GlobalDecl GD, const CGFunctionInfo &FnInfo);
12101210

1211-
void EmitCallAndReturnForThunk(GlobalDecl GD, llvm::Value *Callee,
1212-
const ThunkInfo *Thunk);
1211+
void EmitCallAndReturnForThunk(llvm::Value *Callee, const ThunkInfo *Thunk);
12131212

12141213
/// GenerateThunk - Generate a thunk for the given method.
12151214
void GenerateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,

0 commit comments

Comments
 (0)