summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__tree
diff options
context:
space:
mode:
authorLouis Dionne <ldionne@apple.com>2018-12-06 21:46:17 +0000
committerLouis Dionne <ldionne@apple.com>2018-12-06 21:46:17 +0000
commit3560fbf3049045bf2ac3f3ecb1ddeb73cbe946cf (patch)
treee7c0b1ff885767ec43d44cf846c4ddb3650caa6c /libcxx/include/__tree
parent037ed1befd3ae2677cb09af72214420e80344f0a (diff)
downloadbcm5719-llvm-3560fbf3049045bf2ac3f3ecb1ddeb73cbe946cf.tar.gz
bcm5719-llvm-3560fbf3049045bf2ac3f3ecb1ddeb73cbe946cf.zip
[libc++] Improve diagnostics for non-const comparators and hashers in associative containers
Summary: When providing a non-const-callable comparator in a map or set, the warning diagnostic does not include the point of instantiation of the container that triggered the warning, which makes it difficult to track down the problem. This commit improves the diagnostic by placing it directly in the body of the associative container. The same change is applied to unordered associative containers, which had a similar problem. Finally, this commit cleans up the forward declarations of several map and unordered_map helpers, which are not needed anymore. <rdar://problem/41370747> Reviewers: EricWF, mclow.lists Subscribers: christof, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D48955 llvm-svn: 348529
Diffstat (limited to 'libcxx/include/__tree')
-rw-r--r--libcxx/include/__tree30
1 files changed, 5 insertions, 25 deletions
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index aa7370bfb04..814851085b9 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -40,10 +40,6 @@ template <class _Tp, class _VoidPtr> class __tree_node;
template <class _Key, class _Value>
struct __value_type;
-template <class _Key, class _CP, class _Compare,
- bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
-class __map_value_compare;
-
template <class _Allocator> class __map_node_destructor;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_iterator;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
@@ -966,24 +962,12 @@ private:
};
+template<class _Tp, class _Compare>
#ifndef _LIBCPP_CXX03_LANG
-template <class _Tp, class _Compare, class _Allocator>
-struct __diagnose_tree_helper {
- static constexpr bool __trigger_diagnostics()
- _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
- "the specified comparator type does not provide a const call operator")
- { return true; }
-};
-
-template <class _Key, class _Value, class _KeyComp, class _Alloc>
-struct __diagnose_tree_helper<
- __value_type<_Key, _Value>,
- __map_value_compare<_Key, __value_type<_Key, _Value>, _KeyComp>,
- _Alloc
-> : __diagnose_tree_helper<_Key, _KeyComp, _Alloc>
-{
-};
-#endif // !_LIBCPP_CXX03_LANG
+ _LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
+ "the specified comparator type does not provide a const call operator")
+#endif
+int __diagnose_non_const_comparator();
template <class _Tp, class _Compare, class _Allocator>
class __tree
@@ -1855,10 +1839,6 @@ __tree<_Tp, _Compare, _Allocator>::~__tree()
{
static_assert((is_copy_constructible<value_compare>::value),
"Comparator must be copy-constructible.");
-#ifndef _LIBCPP_CXX03_LANG
- static_assert((__diagnose_tree_helper<_Tp, _Compare, _Allocator>::
- __trigger_diagnostics()), "");
-#endif
destroy(__root());
}
OpenPOWER on IntegriCloud