[PATCH] D45179: [libc++] Add _LIBCPP_ENABLE_NODISCARD and _LIBCPP_NODISCARD_EXT to allow pre-C++2a [[nodiscard]]

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 9 16:01:16 PDT 2018


EricWF updated this revision to Diff 154724.
EricWF retitled this revision from "[libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17" to "[libc++] Add _LIBCPP_ENABLE_NODISCARD and _LIBCPP_NODISCARD_EXT to allow pre-C++2a [[nodiscard]]".
EricWF edited the summary of this revision.
EricWF added a comment.

This updates just about everything in this patch. See the updated description for the overall design.

Specific issues addressed by this patch are:

- Rename `_LIBCPP_FORCE_NODISCARD` to `_LIBCPP_ENABLE_NODISCARD` for consistency.
- Add the `_LIBCPP_NODISCARD_EXT` macro to allow appling `[[nodiscard]]` as a pure extension.
- Document all new user facing macros and how to use them.
- Document the extension in general. (Adding a section in which libc++ should document all its extensions).
- Use `[[clang::warn_unused_result]]` in place of `[[nodiscard]]` when it's not available. All supported clang versions provide this attribute. This applies to `_LIBCPP_NODISCARD_AFTER_CXX17` which may be enabled in before `[[nodiscard]]` is supported.
- Add more tests for all combinations.


https://reviews.llvm.org/D45179

Files:
  docs/UsingLibcxx.rst
  include/__config
  include/memory
  test/libcxx/diagnostics/enable_nodiscard.fail.cpp
  test/libcxx/diagnostics/enable_nodiscard_disable_after_cxx17.fail.cpp
  test/libcxx/diagnostics/enable_nodiscard_disable_nodiscard_ext.fail.cpp
  test/libcxx/diagnostics/nodiscard.fail.cpp
  test/libcxx/diagnostics/nodiscard.pass.cpp
  test/libcxx/diagnostics/nodiscard_aftercxx17.fail.cpp
  test/libcxx/diagnostics/nodiscard_aftercxx17.pass.cpp
  test/libcxx/diagnostics/nodiscard_extensions.fail.cpp
  test/libcxx/diagnostics/nodiscard_extensions.pass.cpp
  utils/libcxx/test/format.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45179.154724.patch
Type: text/x-patch
Size: 16660 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180709/2a80faec/attachment-0001.bin>


More information about the cfe-commits mailing list