[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts
Zinovy Nis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 8 03:43:03 PDT 2020
zinovy.nis marked 2 inline comments as done.
zinovy.nis added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:342
+ // CHECK-NOTES: [[@LINE-5]]:20: note: variable 'a' implicitly captured const here
};
}
----------------
Quuxplusone wrote:
> zinovy.nis wrote:
> > aaron.ballman wrote:
> > > One more test case to try out (it might be a FIXME because I imagine this requires flow control to get right):
> > > ```
> > > A a;
> > > std::move(a);
> > >
> > > auto lambda = [=] {
> > > a.foo(); // Use of 'a' after it was moved
> > > }
> > > ```
> > `a` in lambda is `const`, but it's not moved inside lambda, so my warning is not expected to be shown.
> The "use" of `a` that Aaron was talking about is actually
>
> auto lambda = [=] { a.foo(); };
> ^ here
>
> where the moved-from object is captured-by-copy into the lambda. Making a copy of a moved-from object should warn. (Your patch shouldn't have affected this AFAICT; I think he's just asking for a test to verify+document the currently expected behavior.)
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp#L342
Seems these tests have already been added.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74692/new/
https://reviews.llvm.org/D74692
More information about the cfe-commits
mailing list