[PATCH] D96215: [clang-tidy] Aliasing: Add support for lambda captures.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 4 15:07:56 PDT 2021


NoQ added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/utils/Aliasing.cpp:45
+    // Treat lambda capture by reference as a form of taking a reference.
+    return llvm::any_of(LE->captures(), [Var](const LambdaCapture &C) {
+      return C.capturesVariable() && C.getCaptureKind() == LCK_ByRef &&
----------------
xazax.hun wrote:
> Will this cover generalized captures? E.g.:
> ```
> int i;
> auto lambda = [foo=&i] { return *foo; };
> ```
This one's good; we still react on the operator & inside the init-expression. This one's worse however: `[&foo = i]` (i had such test for the next patch but not for this patch). Let me patch this up.


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

https://reviews.llvm.org/D96215



More information about the cfe-commits mailing list