Skip to content

Commit 80d1f65

Browse files
committed
Fix unused lambda capture in a non-asserts build
For locally scoped lambdas like this there's no particular benefit to explicitly listing captures - or avoiding capturing this. Switch to [&] and make it all easier to maintain. (& driveby change std::function to llvm::function_ref)
1 parent 5baea05 commit 80d1f65

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
775775
DIExpressionCursor Cursor(Expr);
776776
const TargetRegisterInfo &TRI = *Asm->MF->getSubtarget().getRegisterInfo();
777777

778-
// Declare the TargetMachine locally so we don't need to capture `this` in
779-
// the lambda.
780-
TargetMachine &TM = Asm->TM;
781-
auto AddEntry = [&DwarfExpr, &TRI, &TM](const DbgValueLocEntry &Entry,
778+
auto AddEntry = [&](const DbgValueLocEntry &Entry,
782779
DIExpressionCursor &Cursor) {
783780
if (Entry.isLocation()) {
784781
if (!DwarfExpr.addMachineRegExpression(TRI, Cursor,
@@ -797,7 +794,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
797794
TargetIndexLocation Loc = Entry.getTargetIndexLocation();
798795
// TODO TargetIndexLocation is a target-independent. Currently only the
799796
// WebAssembly-specific encoding is supported.
800-
assert(TM.getTargetTriple().isWasm());
797+
assert(Asm->TM.getTargetTriple().isWasm());
801798
DwarfExpr.addWasmLocation(Loc.Index, static_cast<uint64_t>(Loc.Offset));
802799
} else {
803800
llvm_unreachable("Unsupported Entry type.");
@@ -807,7 +804,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
807804

808805
DwarfExpr.addExpression(
809806
std::move(Cursor),
810-
[&AddEntry, &DVal](unsigned Idx, DIExpressionCursor &Cursor) -> bool {
807+
[&](unsigned Idx, DIExpressionCursor &Cursor) -> bool {
811808
return AddEntry(DVal->getLocEntries()[Idx], Cursor);
812809
});
813810

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor,
473473

474474
void DwarfExpression::addExpression(
475475
DIExpressionCursor &&ExprCursor,
476-
std::function<bool(unsigned, DIExpressionCursor &)> InsertArg) {
476+
llvm::function_ref<bool(unsigned, DIExpressionCursor &)> InsertArg) {
477477
// Entry values can currently only cover the initial register location,
478478
// and not any other parts of the following DWARF expression.
479479
assert(!IsEmittingEntryValue && "Can't emit entry value around expression");

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class DwarfExpression {
349349
unsigned FragmentOffsetInBits = 0);
350350
void
351351
addExpression(DIExpressionCursor &&Expr,
352-
std::function<bool(unsigned, DIExpressionCursor &)> InsertArg);
352+
llvm::function_ref<bool(unsigned, DIExpressionCursor &)> InsertArg);
353353

354354
/// If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to
355355
/// the fragment described by \c Expr.

0 commit comments

Comments
 (0)