[llvm-dev] Spurious cast warning for C++?

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 10 07:33:26 PDT 2017


For the case of a redundant or unneeded std::move, I think Clang already
has something like that...

Ah, it doesn't quite catch that particular case.

Richard - would it be reasonable to extend the pessimizing move warning
(well, I guess not - maybe as a separate warning) for cases like this:

void f(const foo&);
void g(foo x) {
  f(std::move(x));
}

Or maybe there's already a clang-tidy check for this sort of redundant move?

On Sun, Apr 9, 2017 at 12:01 PM Brennan Vincent via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> How difficult would it be to add a warning to Clang when the programmer
> performs a cast that provably has no effect?
>
> A particular case I have in mind is someone getting confused and calling
> std::move on an argument to a copy-constructor for a class that doesn't
> implement move semantics.
>
> I would be grateful if someone either (1) told me why this is
> difficult/impossible, or (2) gave me some pointers to where I could
> start trying to implement it...
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170410/4ba08a79/attachment.html>


More information about the llvm-dev mailing list