[llvm] r284364 - ADT: Use LLVM_NODISCARD instead of LLVM_ATTRIBUTE_UNUSED_RESULT for StringRef

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 10:13:50 PST 2016


On Mon, Nov 28, 2016 at 05:18:06PM +0000, David Blaikie via llvm-commits wrote:
> I'm going to +1 Zach here, this doesn't seem like a good use of the
> attribute.

I agree with Zach as well. It is very easy to force bogus return value
use. Glibc's decision to apply this for fwrite/fread is a very good
(bad) example -- there is a simple global marker for checking errors, so
doing it on every call is wrong. It should also be noted that at least
GCC still warns when casting the result to void in some versions. So you
have to assign it to a dummy variable and cast that to void.

Joerg


More information about the llvm-commits mailing list