[llvm-dev] Adding [[nodiscard]] to Compiler.h (original) (raw)

Chandler Carruth via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 4 19:16:05 PDT 2016


On Sun, Sep 4, 2016 at 6:40 PM Justin Bogner <mail at justinbogner.com> wrote:

Chandler Carruth <chandlerc at google.com> writes: > My 2 cents: get rid of LLVMUNUSEDRESULT, and move to LLVMNODISCARD. > > For compilers that support it, it should be a strict superset of features and > functionality. The standard feature was written directly based on the clang > warnunusedresult stuff. > > I would just migrate us onto the spelling and usage pattern that got > standardized. All we have to lose are warnings from compilers other than Clang > until they implement this feature. That seems like not a huge loss to me > honestly.

You might be right. It seems a bit unfortunate that we'd lose these warnings on MSVC and gcc for the time being, but maybe that's better than the usability cost of having two macros that expand to the same thing. Do note though, if we do that this would mean clang is the only compiler we can support this on at all without -std=c++17, since [[nodiscard]] will trigger extension warnings in earlier standard modes.

Yea, I dunno.

If you end up wanting two macros, I'd suggest:

LLVM_NODISCARD

which works exactly as [[nodiscard]], and

LLVM_NODISCARD_FUNCTION

which works the way our current macro works. My two cents. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160905/164c94e3/attachment.html>



More information about the llvm-dev mailing list