[PATCH] D79616: [NFC][DwarfDebug] Avoid default capturing when using lambdas

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 23:57:38 PDT 2020


dblaikie added a comment.

> It is bad practice to capture by default (via [&] in this case) when using lambdas

I'd say quite the opposite - default reference capture should be used by default for any lambda that does not escape its context - same as any other code block. (I think this is more unambiguous when the lambda is never named, and just immediately passed into another function like ```llvm::any_of```, and I'm not 100% on never enumerating captures when a lambda is named and maybe called several times in more surprising/distant places - but this lambda is called directly, and exactly once, which makes me question the use of a lambda here - I'd consider pulling it out as a separate named function, or just removing the lambda entirely & adding a comment block describing the purpose of the code inline)

Please revert this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79616/new/

https://reviews.llvm.org/D79616





More information about the llvm-commits mailing list