[PATCH] D26596: [RFC] Add _LIBCPP_NO_DISCARD and apply it to `Container::empty()`, `unique_ptr<T>::release()`, and `Lockable::try_lock()`
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 14 00:18:31 PST 2016
EricWF updated this revision to Diff 77772.
EricWF added a comment.
Add final touches. This patch is ready to go.
@chandlerc mentioned he would still like to see more per-function granularity for enabling/disabling the libc++ [[nodiscard]] macro in order to ease adoption in large code bases. However I'm concerned about the cost of maintaining 100+ user-visible configuration macros. This current patch attempts to find a happy medium by grouping similar functions into a single macro; which can be sub-divided further if needed.
As a general rule functions where [[nodiscard]] may yield false positives (ie `unique_ptr::release()`) should always have their own group, since fixing the false-positives is a stylistic change. Functions where a discarded value is always a bug, either for correctness reasons (ie `try_lock()`) or because the call has no side-effects (ie `string::empty`), may be grouped together as appropriate; Warnings generated by these groups should either be rare or high priority bugs. Dividing groups in this manner attempts to maximize adaptability while being reasonably maintainable.
@mclow.lists Any last words?
https://reviews.llvm.org/D26596
Files:
docs/UsingLibcxx.rst
include/__config
include/__hash_table
include/__mutex_base
include/algorithm
include/deque
include/ext/hash_map
include/forward_list
include/list
include/locale
include/map
include/memory
include/mutex
include/regex
include/set
include/shared_mutex
include/string
include/string_view
include/thread
include/unordered_map
include/unordered_set
include/vector
test/libcxx/containers/no-discard-disable.fail.cpp
test/libcxx/containers/no-discard.fail.cpp
test/libcxx/test/config.py
test/libcxx/thread/thread.mutex/try_lock_no_discard.fail.cpp
test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
test/libcxx/utilities/memory/disable_no_discard_smart_ptr_observers.fail.cpp
test/libcxx/utilities/memory/no_discard_smart_ptr_observers.fail.cpp
test/libcxx/utilities/memory/unique.ptr/disable_no_discard_release.fail.cpp
test/libcxx/utilities/memory/unique.ptr/no_discard_release.fail.cpp
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26596.77772.patch
Type: text/x-patch
Size: 59518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161114/5cd2e278/attachment-0001.bin>
More information about the cfe-commits
mailing list