[PATCH] D129835: [clang] adds a discardable attribute
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 15 09:21:57 PDT 2022
aaron.ballman added a comment.
> When we have a function that can have its value discarded, we can use [[clang::discardable]] to indicate that the `[[nodiscard]]` attribute should be ignored.
Alternatively, you can scope the pragma and declarations appropriately and then we don't need to add a new attribute. Is there a reason that wouldn't work for you?
(This attribute would be interesting to consider if we added a feature flag like `-fdiagnose-discarded-results` where the default is as-if everything was declared `nodiscard` and then you could mark the APIs with `[[clang::discardable]]` for the few whose results don't matter. However, that's also a much bigger feature because system headers are a challenge.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129835/new/
https://reviews.llvm.org/D129835
More information about the cfe-commits
mailing list