[llvm] 80d1f65 - Fix unused lambda capture in a non-asserts build
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 11 00:22:30 PST 2021
Author: David Blaikie
Date: 2021-03-11T00:22:18-08:00
New Revision: 80d1f657a157b2e1558ecfc161bad062592ba5bf
URL: https://github.com/llvm/llvm-project/commit/80d1f657a157b2e1558ecfc161bad062592ba5bf
DIFF: https://github.com/llvm/llvm-project/commit/80d1f657a157b2e1558ecfc161bad062592ba5bf.diff
LOG: 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)
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index cba36ab584e9..002687b9375a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -775,10 +775,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
DIExpressionCursor Cursor(Expr);
const TargetRegisterInfo &TRI = *Asm->MF->getSubtarget().getRegisterInfo();
- // Declare the TargetMachine locally so we don't need to capture `this` in
- // the lambda.
- TargetMachine &TM = Asm->TM;
- auto AddEntry = [&DwarfExpr, &TRI, &TM](const DbgValueLocEntry &Entry,
+ auto AddEntry = [&](const DbgValueLocEntry &Entry,
DIExpressionCursor &Cursor) {
if (Entry.isLocation()) {
if (!DwarfExpr.addMachineRegExpression(TRI, Cursor,
@@ -797,7 +794,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
TargetIndexLocation Loc = Entry.getTargetIndexLocation();
// TODO TargetIndexLocation is a target-independent. Currently only the
// WebAssembly-specific encoding is supported.
- assert(TM.getTargetTriple().isWasm());
+ assert(Asm->TM.getTargetTriple().isWasm());
DwarfExpr.addWasmLocation(Loc.Index, static_cast<uint64_t>(Loc.Offset));
} else {
llvm_unreachable("Unsupported Entry type.");
@@ -807,7 +804,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
DwarfExpr.addExpression(
std::move(Cursor),
- [&AddEntry, &DVal](unsigned Idx, DIExpressionCursor &Cursor) -> bool {
+ [&](unsigned Idx, DIExpressionCursor &Cursor) -> bool {
return AddEntry(DVal->getLocEntries()[Idx], Cursor);
});
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
index 8dc260130f46..6409c39e7849 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -473,7 +473,7 @@ void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor,
void DwarfExpression::addExpression(
DIExpressionCursor &&ExprCursor,
- std::function<bool(unsigned, DIExpressionCursor &)> InsertArg) {
+ llvm::function_ref<bool(unsigned, DIExpressionCursor &)> InsertArg) {
// Entry values can currently only cover the initial register location,
// and not any other parts of the following DWARF expression.
assert(!IsEmittingEntryValue && "Can't emit entry value around expression");
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index 2e5edf18b38d..513e9072309e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -349,7 +349,7 @@ class DwarfExpression {
unsigned FragmentOffsetInBits = 0);
void
addExpression(DIExpressionCursor &&Expr,
- std::function<bool(unsigned, DIExpressionCursor &)> InsertArg);
+ llvm::function_ref<bool(unsigned, DIExpressionCursor &)> InsertArg);
/// If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to
/// the fragment described by \c Expr.
More information about the llvm-commits
mailing list