Febbe added a comment.

In D137205#4047828 <https://reviews.llvm.org/D137205#4047828>, @Skylion007 
wrote:

> I am trying this in the wild and getting some false positives where it tries 
> to call std::move inside loop conditions and in the boolean condition for an 
> if statement. Stuff like:
>
>   if (SmartPtr new_ptr = steal_ptr(std::move(old_ptr))) {
>     ...
>   }
>   else {
>     return old_ptr; // Now it's moved from and invalid
>   }
>
> Also this can be happen for similar boolean conditionals in while, for, do 
> while loops.
>
> Interestingly, the logic in bugprone-use-after-move flags this error so maybe 
> we can reuse some of that logic to detect bad std::move.

Does this only happen on "init-statements" of while/if/switch?
And thanks for the catch, I'll take a look into it as soon I have more time.

Btw. I've oriented myself at the "bugprone-use-after-move" check, but simply 
inverting it does not work here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to