<div dir="ltr">I agree, but clearly this person chose a particular style, and I wasn't trying to revise their code style, just to fix some the Bazel build, which uses -Werror.<div><br></div><div>The way that `assert` can affect a lambda's capture list seems like a particularly good argument for having a project wide style recommendation to never use explicit capture lists.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 28, 2022 at 9:45 AM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">FWIW, I think it's probably simpler/more maintainable to default capture by reference ("[&]") if a lambda doesn't escape its scope (if it's never type erased/put in a std::function or equivalent). Avoids assert/non-assert unused issues, having to maintain/update the list when the code changes and makes a capture live/dead/etc.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 23, 2022 at 2:09 PM Reid Kleckner via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Reid Kleckner<br>
Date: 2022-02-23T14:07:04-08:00<br>
New Revision: 1d1b089c5d503e2fc8697887411730105f66c774<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774.diff</a><br>
<br>
LOG: Fix more unused lambda capture warnings, NFC<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    clang/lib/CodeGen/CGOpenMPRuntime.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp<br>
index b4033da890c4..3f4a78ddbf3c 100644<br>
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp<br>
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp<br>
@@ -10358,8 +10358,8 @@ void CGOpenMPRuntime::emitTargetCall(<br>
   llvm::Value *MapTypesArray = nullptr;<br>
   llvm::Value *MapNamesArray = nullptr;<br>
   // Generate code for the host fallback function.<br>
-  auto &&FallbackGen = [this, OutlinedFn, &D, &CapturedVars, RequiresOuterTask,<br>
-                        &CS, OffloadingMandatory](CodeGenFunction &CGF) {<br>
+  auto &&FallbackGen = [this, &D, OutlinedFn, &CapturedVars, RequiresOuterTask, &CS,<br>
+                        OffloadingMandatory](CodeGenFunction &CGF) {<br>
     if (OffloadingMandatory) {<br>
       CGF.Builder.CreateUnreachable();<br>
     } else {<br>
@@ -10371,9 +10371,8 @@ void CGOpenMPRuntime::emitTargetCall(<br>
     }<br>
   };<br>
   // Fill up the pointer arrays and transfer execution to the device.<br>
-  auto &&ThenGen = [this, Device, OutlinedFn, OutlinedFnID, &D, &InputInfo,<br>
-                    &MapTypesArray, &MapNamesArray, &CS, RequiresOuterTask,<br>
-                    &CapturedVars, SizeEmitter,<br>
+  auto &&ThenGen = [this, Device, OutlinedFnID, &D, &InputInfo,<br>
+                    &MapTypesArray, &MapNamesArray, SizeEmitter,<br>
                     FallbackGen](CodeGenFunction &CGF, PrePostActionTy &) {<br>
     if (Device.getInt() == OMPC_DEVICE_ancestor) {<br>
       // Reverse offloading is not supported, so just execute on the host.<br>
@@ -10392,6 +10391,7 @@ void CGOpenMPRuntime::emitTargetCall(<br>
<br>
     // From this point on, we need to have an ID of the target region defined.<br>
     assert(OutlinedFnID && "Invalid outlined function ID!");<br>
+    (void)OutlinedFnID;<br>
<br>
     // Emit device ID if any.<br>
     llvm::Value *DeviceID;<br>
@@ -10529,8 +10529,7 @@ void CGOpenMPRuntime::emitTargetCall(<br>
   };<br>
<br>
   // Notify that the host version must be executed.<br>
-  auto &&ElseGen = [this, &D, OutlinedFn, &CS, &CapturedVars, RequiresOuterTask,<br>
-                    FallbackGen](CodeGenFunction &CGF, PrePostActionTy &) {<br>
+  auto &&ElseGen = [FallbackGen](CodeGenFunction &CGF, PrePostActionTy &) {<br>
     FallbackGen(CGF);<br>
   };<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</blockquote></div>