[PATCH] D45163: [Sema] -Wunused-value: diagnose unused std::move() call results.
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 3 13:01:44 PDT 2018
Quuxplusone added a comment.
In https://reviews.llvm.org/D45163#1055957, @lebedev.ri wrote:
> In https://reviews.llvm.org/D45163#1055856, @rjmccall wrote:
>
> > Well, we should feel welcome to submit patches to the C++ library implementations, I think. I can understand why Marshall is waiting to just do this until he gets a comprehensive committee paper, but he might consider taking a patch in the meantime.
>
>
> That has been discussed, and it's not going to happen. Ask him if you want more info.
You say a library patch is not going to happen, but isn't that library patch literally https://reviews.llvm.org/D45179, which has been accepted (although I just left a comment explaining why the current macro-soup is suboptimal)?
> TLDW: `std::move()` is "The Assign Operator (`a = b;`) of RAII". It would be good to diagnose such a problem, and not just rely that some day the std libs will mark it with the attribute.
> BTW, even when they do, even for libcxx, it won't be of any immediate use to LLVM, we will need to provide a define (see https://reviews.llvm.org/D45179) to actually enable that attribute, because LLVM is using C++11, not C++17/something...
Yes, but that patch (which you've written in https://reviews.llvm.org/D45179) is essentially just "if C++17, `[[nodiscard]]`, else `__attribute__((warn_unused_result))`." The library vendor is completely free to mark nodiscard-ish function with [[nodiscard]] or any other attribute they want to. And if I'm not mistaken, https://reviews.llvm.org/D45179 is a step in that direction.
Repository:
rC Clang
https://reviews.llvm.org/D45163
More information about the cfe-commits
mailing list