Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit bb177a9

Browse files
committed
Remove unused lambda captures. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291939 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 48c6249 commit bb177a9

6 files changed

+25
-27
lines changed

docs/ReleaseNotes.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Major New Features
5252
Improvements to Clang's diagnostics
5353
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5454

55-
- ...
55+
- -Wunused-lambda-capture warns when a variable explicitly captured
56+
by a lambda is not used in the body of the lambda.
5657

5758
New Compiler Flags
5859
------------------

lib/AST/CXXInheritance.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
8888
const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
8989
// FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
9090
return lookupInBases(
91-
[this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
91+
[BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
9292
return FindBaseClass(Specifier, Path, BaseDecl);
9393
},
9494
Paths);
@@ -109,7 +109,7 @@ bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {
109109
const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
110110
// FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
111111
return lookupInBases(
112-
[this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
112+
[BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
113113
return FindVirtualBaseClass(Specifier, Path, BaseDecl);
114114
},
115115
Paths);

lib/AST/MicrosoftMangle.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2997,14 +2997,14 @@ void MicrosoftMangleContextImpl::mangleStringLiteral(const StringLiteral *SL,
29972997
// N.B. The length is in terms of bytes, not characters.
29982998
Mangler.mangleNumber(SL->getByteLength() + SL->getCharByteWidth());
29992999

3000-
auto GetLittleEndianByte = [&Mangler, &SL](unsigned Index) {
3000+
auto GetLittleEndianByte = [&SL](unsigned Index) {
30013001
unsigned CharByteWidth = SL->getCharByteWidth();
30023002
uint32_t CodeUnit = SL->getCodeUnit(Index / CharByteWidth);
30033003
unsigned OffsetInCodeUnit = Index % CharByteWidth;
30043004
return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
30053005
};
30063006

3007-
auto GetBigEndianByte = [&Mangler, &SL](unsigned Index) {
3007+
auto GetBigEndianByte = [&SL](unsigned Index) {
30083008
unsigned CharByteWidth = SL->getCharByteWidth();
30093009
uint32_t CodeUnit = SL->getCodeUnit(Index / CharByteWidth);
30103010
unsigned OffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);

lib/CodeGen/CGOpenMPRuntime.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -4006,8 +4006,8 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
40064006
DepTaskArgs[5] = CGF.Builder.getInt32(0);
40074007
DepTaskArgs[6] = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
40084008
}
4009-
auto &&ThenCodeGen = [this, Loc, &Data, TDBase, KmpTaskTQTyRD,
4010-
NumDependencies, &TaskArgs,
4009+
auto &&ThenCodeGen = [this, &Data, TDBase, KmpTaskTQTyRD, NumDependencies,
4010+
&TaskArgs,
40114011
&DepTaskArgs](CodeGenFunction &CGF, PrePostActionTy &) {
40124012
if (!Data.Tied) {
40134013
auto PartIdFI = std::next(KmpTaskTQTyRD->field_begin(), KmpTaskTPartId);
@@ -4562,7 +4562,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
45624562
}
45634563
if (XExpr) {
45644564
auto *VD = cast<VarDecl>(cast<DeclRefExpr>(*ILHS)->getDecl());
4565-
auto &&AtomicRedGen = [BO, VD, IPriv,
4565+
auto &&AtomicRedGen = [BO, VD,
45664566
Loc](CodeGenFunction &CGF, const Expr *XExpr,
45674567
const Expr *EExpr, const Expr *UpExpr) {
45684568
LValue X = CGF.EmitLValue(XExpr);
@@ -4572,7 +4572,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
45724572
CGF.EmitOMPAtomicSimpleUpdateExpr(
45734573
X, E, BO, /*IsXLHSInRHSPart=*/true,
45744574
llvm::AtomicOrdering::Monotonic, Loc,
4575-
[&CGF, UpExpr, VD, IPriv, Loc](RValue XRValue) {
4575+
[&CGF, UpExpr, VD, Loc](RValue XRValue) {
45764576
CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
45774577
PrivateScope.addPrivate(
45784578
VD, [&CGF, VD, XRValue, Loc]() -> Address {
@@ -5988,8 +5988,8 @@ void CGOpenMPRuntime::emitTargetCall(CodeGenFunction &CGF,
59885988
OffloadError);
59895989

59905990
// Fill up the pointer arrays and transfer execution to the device.
5991-
auto &&ThenGen = [&Ctx, &BasePointers, &Pointers, &Sizes, &MapTypes, Device,
5992-
OutlinedFnID, OffloadError, OffloadErrorQType,
5991+
auto &&ThenGen = [&BasePointers, &Pointers, &Sizes, &MapTypes, Device,
5992+
OutlinedFnID, OffloadError,
59935993
&D](CodeGenFunction &CGF, PrePostActionTy &) {
59945994
auto &RT = CGF.CGM.getOpenMPRuntime();
59955995
// Emit the offloading arrays.
@@ -6275,8 +6275,8 @@ void CGOpenMPRuntime::emitTargetDataCalls(
62756275
// Generate the code for the opening of the data environment. Capture all the
62766276
// arguments of the runtime call by reference because they are used in the
62776277
// closing of the region.
6278-
auto &&BeginThenGen = [&D, &CGF, Device, &Info, &CodeGen, &NoPrivAction](
6279-
CodeGenFunction &CGF, PrePostActionTy &) {
6278+
auto &&BeginThenGen = [&D, Device, &Info, &CodeGen](CodeGenFunction &CGF,
6279+
PrePostActionTy &) {
62806280
// Fill up the arrays with all the mapped variables.
62816281
MappableExprsHandler::MapBaseValuesArrayTy BasePointers;
62826282
MappableExprsHandler::MapValuesArrayTy Pointers;
@@ -6322,8 +6322,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
63226322
};
63236323

63246324
// Generate code for the closing of the data region.
6325-
auto &&EndThenGen = [&CGF, Device, &Info](CodeGenFunction &CGF,
6326-
PrePostActionTy &) {
6325+
auto &&EndThenGen = [Device, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
63276326
assert(Info.isValid() && "Invalid data environment closing arguments.");
63286327

63296328
llvm::Value *BasePointersArrayArg = nullptr;
@@ -6401,7 +6400,7 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
64016400
"Expecting either target enter, exit data, or update directives.");
64026401

64036402
// Generate the code for the opening of the data environment.
6404-
auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) {
6403+
auto &&ThenGen = [&D, Device](CodeGenFunction &CGF, PrePostActionTy &) {
64056404
// Fill up the arrays with all the mapped variables.
64066405
MappableExprsHandler::MapBaseValuesArrayTy BasePointers;
64076406
MappableExprsHandler::MapValuesArrayTy Pointers;

lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericParallelCall(
533533
ArrayRef<llvm::Value *> CapturedVars, const Expr *IfCond) {
534534
llvm::Function *Fn = cast<llvm::Function>(OutlinedFn);
535535

536-
auto &&L0ParallelGen = [this, Fn, &CapturedVars](CodeGenFunction &CGF,
537-
PrePostActionTy &) {
536+
auto &&L0ParallelGen = [this, Fn](CodeGenFunction &CGF, PrePostActionTy &) {
538537
CGBuilderTy &Bld = CGF.Builder;
539538

540539
// Prepare for parallel region. Indicate the outlined function.
@@ -565,8 +564,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericParallelCall(
565564

566565
auto &&SeqGen = [this, Fn, &CapturedVars, &Args](CodeGenFunction &CGF,
567566
PrePostActionTy &) {
568-
auto &&CodeGen = [this, Fn, &CapturedVars, &Args](CodeGenFunction &CGF,
569-
PrePostActionTy &Action) {
567+
auto &&CodeGen = [this, Fn, &CapturedVars](CodeGenFunction &CGF,
568+
PrePostActionTy &Action) {
570569
Action.Enter(CGF);
571570

572571
llvm::SmallVector<llvm::Value *, 16> OutlinedFnArgs;

lib/CodeGen/CGStmtOpenMP.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ void CodeGenFunction::EmitOMPReductionClauseInit(
986986
OriginalBaseLValue);
987987
// Store the address of the original variable associated with the LHS
988988
// implicit variable.
989-
PrivateScope.addPrivate(LHSVD, [this, OASELValueLB]() -> Address {
989+
PrivateScope.addPrivate(LHSVD, [OASELValueLB]() -> Address {
990990
return OASELValueLB.getAddress();
991991
});
992992
// Emit reduction copy.
@@ -1040,9 +1040,8 @@ void CodeGenFunction::EmitOMPReductionClauseInit(
10401040
*this, OrigVD->getType(), ASELValue.getType(), OriginalBaseLValue);
10411041
// Store the address of the original variable associated with the LHS
10421042
// implicit variable.
1043-
PrivateScope.addPrivate(LHSVD, [this, ASELValue]() -> Address {
1044-
return ASELValue.getAddress();
1045-
});
1043+
PrivateScope.addPrivate(
1044+
LHSVD, [ASELValue]() -> Address { return ASELValue.getAddress(); });
10461045
// Emit reduction copy.
10471046
bool IsRegistered = PrivateScope.addPrivate(
10481047
OrigVD, [this, OrigVD, PrivateVD, BaseLValue, ASELValue,
@@ -2633,7 +2632,7 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(const OMPExecutableDirective &S,
26332632
for (const auto *C : S.getClausesOfKind<OMPDependClause>())
26342633
for (auto *IRef : C->varlists())
26352634
Data.Dependences.push_back(std::make_pair(C->getDependencyKind(), IRef));
2636-
auto &&CodeGen = [PartId, &S, &Data, CS, &BodyGen, &LastprivateDstsOrigs](
2635+
auto &&CodeGen = [&Data, CS, &BodyGen, &LastprivateDstsOrigs](
26372636
CodeGenFunction &CGF, PrePostActionTy &Action) {
26382637
// Set proper addresses for generated private copies.
26392638
OMPPrivateScope Scope(CGF);
@@ -3250,7 +3249,7 @@ static void EmitOMPAtomicCaptureExpr(CodeGenFunction &CGF, bool IsSeqCst,
32503249
NewVValType = XRValExpr->getType();
32513250
auto *ERValExpr = IsXLHSInRHSPart ? RHS : LHS;
32523251
auto &&Gen = [&CGF, &NewVVal, UE, ExprRValue, XRValExpr, ERValExpr,
3253-
IsSeqCst, IsPostfixUpdate](RValue XRValue) -> RValue {
3252+
IsPostfixUpdate](RValue XRValue) -> RValue {
32543253
CodeGenFunction::OpaqueValueMapping MapExpr(CGF, ERValExpr, ExprRValue);
32553254
CodeGenFunction::OpaqueValueMapping MapX(CGF, XRValExpr, XRValue);
32563255
RValue Res = CGF.EmitAnyExpr(UE);
@@ -3277,7 +3276,7 @@ static void EmitOMPAtomicCaptureExpr(CodeGenFunction &CGF, bool IsSeqCst,
32773276
NewVValType = X->getType().getNonReferenceType();
32783277
ExprRValue = convertToType(CGF, ExprRValue, E->getType(),
32793278
X->getType().getNonReferenceType(), Loc);
3280-
auto &&Gen = [&CGF, &NewVVal, ExprRValue](RValue XRValue) -> RValue {
3279+
auto &&Gen = [&NewVVal, ExprRValue](RValue XRValue) -> RValue {
32813280
NewVVal = XRValue;
32823281
return ExprRValue;
32833282
};

0 commit comments

Comments
 (0)