summaryrefslogtreecommitdiffstats
path: root/libcxx/include/unordered_map
diff options
context:
space:
mode:
authorLouis Dionne <ldionne@apple.com>2019-04-11 16:14:56 +0000
committerLouis Dionne <ldionne@apple.com>2019-04-11 16:14:56 +0000
commit7c142fcc06850c7cee3cdb07e98cc57f04ee5e8b (patch)
tree91fc657ab4f9df17c22b8d4c2c6199bb4cb5f2a5 /libcxx/include/unordered_map
parentb971b59709075a28fa64e31564cf7d6f0bc9fecf (diff)
downloadbcm5719-llvm-7c142fcc06850c7cee3cdb07e98cc57f04ee5e8b.tar.gz
bcm5719-llvm-7c142fcc06850c7cee3cdb07e98cc57f04ee5e8b.zip
[libc++] Make sure we don't eagerly diagnose non-const comparators for containers of incomplete types
Summary: In r348529, I improved the library-defined diagnostic for using containers with a non-const comparator/hasher. However, the check is now performed too early, which leads to the diagnostic being emitted in cases where it shouldn't. See PR41360 for details. This patch moves the diagnostic to the destructor of the containers, which means that the diagnostic will only be emitted when the container is instantiated at a point where the comparator and the key/value are required to be complete. We still retain better diagnostics than before r348529, because the diagnostics are performed in the containers themselves instead of __tree and __hash_table. As a drive-by fix, I improved the diagnostic to mention that we can't find a _viable_ const call operator, as suggested by EricWF in PR41360. Reviewers: EricWF, mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits, zoecarver Tags: #libc Differential Revision: https://reviews.llvm.org/D60540 llvm-svn: 358189
Diffstat (limited to 'libcxx/include/unordered_map')
-rw-r--r--libcxx/include/unordered_map14
1 files changed, 10 insertions, 4 deletions
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 7ae9805d81d..42057c5d3fd 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -852,7 +852,6 @@ public:
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
@@ -963,7 +962,11 @@ public:
const allocator_type& __a)
: unordered_map(__il, __n, __hf, key_equal(), __a) {}
#endif
- // ~unordered_map() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ ~unordered_map() {
+ static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
+ }
+
_LIBCPP_INLINE_VISIBILITY
unordered_map& operator=(const unordered_map& __u)
{
@@ -1678,7 +1681,6 @@ public:
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
- static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
@@ -1787,7 +1789,11 @@ public:
const allocator_type& __a)
: unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
#endif
- // ~unordered_multimap() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ ~unordered_multimap() {
+ static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
+ }
+
_LIBCPP_INLINE_VISIBILITY
unordered_multimap& operator=(const unordered_multimap& __u)
{
OpenPOWER on IntegriCloud