[PATCH] D67292: [clang-tidy] Fix bug in bugprone-use-after-move check
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 6 13:50:27 PDT 2019
gribozavr added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/bugprone-use-after-move.cpp:1198
+ }
+ }
for (int i = 0; i < 10; ++i) {
----------------
ymandel wrote:
> gribozavr wrote:
> > Unless you think it is redundant, could you also add
> >
> > ```
> > if (A a1; A(std::move(a2)).getInt() > 0) {}
> > ```
> >
> > Also some true positive tests would be good:
> >
> > ```
> > if (A a1; A(std::move(a2)).getInt() > A(std::move(a2)).getInt()) {}
> > ```
> >
> > ```
> > A a1;
> > if (A a2 = std::move(a1); A(std::move(a1)) > 0) {}
> > ```
> Done, but any idea why everything in this function is placed inside a loop? Looks like its just for scoping, but then why not just a compound statement, as is done above? This feels very odd.
I think it is to ensure that the checker understands the sequencing. If it didn't, then the loop would trigger the "moved twice" logic.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67292/new/
https://reviews.llvm.org/D67292
More information about the cfe-commits
mailing list