[PATCH] D131780: [clang-tidy] Do not trigger cppcoreguidelines-avoid-const-or-ref-data-members on lambda captures

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 17 23:38:51 PDT 2022


carlosgalvezp added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp:191
+  auto r5 = [&x5]{};
+}
----------------
njames93 wrote:
> njames93 wrote:
> > Can you add some cases with implicit capture (using [=] and [&])
> I should have been more clear, you need to actually use the variables inside the lambda to implicitly capture them.
Thanks, didn't know that! 

It's actually quite interesting, implicit lambda captures never trigger an error:
https://godbolt.org/z/cErf4jv8E

But it's probably good to keep the test anyway in case the lambda implementation changes.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131780



More information about the cfe-commits mailing list