[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 7 07:28:36 PST 2020
Quuxplusone 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
};
}
----------------
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.)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74692/new/
https://reviews.llvm.org/D74692
More information about the cfe-commits
mailing list