Skip to content

Commit e4a5562

Browse files
committed
Revert "[libc++] Use addressof in unordered_map."
This reverts commit cab9616. This breaks the CI.
1 parent b7fd91c commit e4a5562

17 files changed

+30
-527
lines changed

libcxx/include/__hash_table

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ public:
308308
_LIBCPP_INLINE_VISIBILITY
309309
__hash_iterator& operator=(const __hash_iterator& __i)
310310
{
311-
if (this != _VSTD::addressof(__i))
311+
if (this != &__i)
312312
{
313-
__get_db()->__iterator_copy(this, _VSTD::addressof(__i));
313+
__get_db()->__iterator_copy(this, &__i);
314314
__node_ = __i.__node_;
315315
}
316316
return *this;
@@ -406,7 +406,7 @@ public:
406406
: __node_(__x.__node_)
407407
{
408408
#if _LIBCPP_DEBUG_LEVEL == 2
409-
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
409+
__get_db()->__iterator_copy(this, &__x);
410410
#endif
411411
}
412412

@@ -415,7 +415,7 @@ public:
415415
__hash_const_iterator(const __hash_const_iterator& __i)
416416
: __node_(__i.__node_)
417417
{
418-
__get_db()->__iterator_copy(this, _VSTD::addressof(__i));
418+
__get_db()->__iterator_copy(this, &__i);
419419
}
420420

421421
_LIBCPP_INLINE_VISIBILITY
@@ -427,9 +427,9 @@ public:
427427
_LIBCPP_INLINE_VISIBILITY
428428
__hash_const_iterator& operator=(const __hash_const_iterator& __i)
429429
{
430-
if (this != _VSTD::addressof(__i))
430+
if (this != &__i)
431431
{
432-
__get_db()->__iterator_copy(this, _VSTD::addressof(__i));
432+
__get_db()->__iterator_copy(this, &__i);
433433
__node_ = __i.__node_;
434434
}
435435
return *this;
@@ -523,7 +523,7 @@ public:
523523
__bucket_(__i.__bucket_),
524524
__bucket_count_(__i.__bucket_count_)
525525
{
526-
__get_db()->__iterator_copy(this, _VSTD::addressof(__i));
526+
__get_db()->__iterator_copy(this, &__i);
527527
}
528528

529529
_LIBCPP_INLINE_VISIBILITY
@@ -535,9 +535,9 @@ public:
535535
_LIBCPP_INLINE_VISIBILITY
536536
__hash_local_iterator& operator=(const __hash_local_iterator& __i)
537537
{
538-
if (this != _VSTD::addressof(__i))
538+
if (this != &__i)
539539
{
540-
__get_db()->__iterator_copy(this, _VSTD::addressof(__i));
540+
__get_db()->__iterator_copy(this, &__i);
541541
__node_ = __i.__node_;
542542
__bucket_ = __i.__bucket_;
543543
__bucket_count_ = __i.__bucket_count_;
@@ -655,7 +655,7 @@ public:
655655
__bucket_count_(__x.__bucket_count_)
656656
{
657657
#if _LIBCPP_DEBUG_LEVEL == 2
658-
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
658+
__get_db()->__iterator_copy(this, &__x);
659659
#endif
660660
}
661661

@@ -666,7 +666,7 @@ public:
666666
__bucket_(__i.__bucket_),
667667
__bucket_count_(__i.__bucket_count_)
668668
{
669-
__get_db()->__iterator_copy(this, _VSTD::addressof(__i));
669+
__get_db()->__iterator_copy(this, &__i);
670670
}
671671

672672
_LIBCPP_INLINE_VISIBILITY
@@ -678,9 +678,9 @@ public:
678678
_LIBCPP_INLINE_VISIBILITY
679679
__hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i)
680680
{
681-
if (this != _VSTD::addressof(__i))
681+
if (this != &__i)
682682
{
683-
__get_db()->__iterator_copy(this, _VSTD::addressof(__i));
683+
__get_db()->__iterator_copy(this, &__i);
684684
__node_ = __i.__node_;
685685
__bucket_ = __i.__bucket_;
686686
__bucket_count_ = __i.__bucket_count_;
@@ -1615,7 +1615,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
16151615
__u.size() = 0;
16161616
}
16171617
#if _LIBCPP_DEBUG_LEVEL == 2
1618-
__get_db()->swap(this, _VSTD::addressof(__u));
1618+
__get_db()->swap(this, &__u);
16191619
#endif
16201620
}
16211621

@@ -2021,7 +2021,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
20212021
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
20222022
const_iterator __p, __node_pointer __cp)
20232023
{
2024-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
2024+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
20252025
"unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
20262026
" referring to this unordered container");
20272027
if (__p != end() && key_eq()(*__p, __cp->__value_))
@@ -2148,7 +2148,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
21482148
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
21492149
const_iterator __p, _Args&&... __args)
21502150
{
2151-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
2151+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
21522152
"unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
21532153
" referring to this unordered container");
21542154
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
@@ -2472,7 +2472,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
24722472
__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
24732473
{
24742474
__next_pointer __np = __p.__node_;
2475-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
2475+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
24762476
"unordered container erase(iterator) called with an iterator not"
24772477
" referring to this container");
24782478
_LIBCPP_DEBUG_ASSERT(__p != end(),
@@ -2492,10 +2492,10 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
24922492
__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
24932493
const_iterator __last)
24942494
{
2495-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this,
2495+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
24962496
"unordered container::erase(iterator, iterator) called with an iterator not"
24972497
" referring to this container");
2498-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this,
2498+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
24992499
"unordered container::erase(iterator, iterator) called with an iterator not"
25002500
" referring to this container");
25012501
for (const_iterator __p = __first; __first != __last; __p = __first)
@@ -2727,7 +2727,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
27272727
__u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
27282728
__u.__p1_.first().__ptr();
27292729
#if _LIBCPP_DEBUG_LEVEL == 2
2730-
__get_db()->swap(this, _VSTD::addressof(__u));
2730+
__get_db()->swap(this, &__u);
27312731
#endif
27322732
}
27332733

libcxx/include/unordered_map

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
519519
#include <__functional/is_transparent.h>
520520
#include <__hash_table>
521521
#include <__iterator/iterator_traits.h>
522-
#include <__memory/addressof.h>
523522
#include <__node_handle>
524523
#include <__utility/forward.h>
525524
#include <compare>
@@ -1187,7 +1186,7 @@ public:
11871186
{return __table_.__insert_unique(__x);}
11881187

11891188
iterator insert(const_iterator __p, const value_type& __x) {
1190-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i()_VSTD::addressof(__p) == this,
1189+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
11911190
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not "
11921191
"referring to this unordered_map");
11931192
((void)__p);
@@ -1208,7 +1207,7 @@ public:
12081207
{return __table_.__insert_unique(_VSTD::move(__x));}
12091208

12101209
iterator insert(const_iterator __p, value_type&& __x) {
1211-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
1210+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
12121211
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
12131212
" referring to this unordered_map");
12141213
((void)__p);
@@ -1226,7 +1225,7 @@ public:
12261225
_LIBCPP_INLINE_VISIBILITY
12271226
iterator insert(const_iterator __p, _Pp&& __x)
12281227
{
1229-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
1228+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
12301229
"unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
12311230
" referring to this unordered_map");
12321231
((void)__p);
@@ -1242,7 +1241,7 @@ public:
12421241
template <class... _Args>
12431242
_LIBCPP_INLINE_VISIBILITY
12441243
iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1245-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
1244+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
12461245
"unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
12471246
" referring to this unordered_map");
12481247
((void)__p);
@@ -1274,7 +1273,7 @@ public:
12741273
_LIBCPP_INLINE_VISIBILITY
12751274
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
12761275
{
1277-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__h)) == this,
1276+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
12781277
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
12791278
" referring to this unordered_map");
12801279
((void)__h);
@@ -1285,7 +1284,7 @@ public:
12851284
_LIBCPP_INLINE_VISIBILITY
12861285
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
12871286
{
1288-
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i()_VSTD::addressof(__h) == this,
1287+
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
12891288
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
12901289
" referring to this unordered_map");
12911290
((void)__h);
@@ -1693,7 +1692,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16931692
{
16941693
_VSTD::__debug_db_insert_c(this);
16951694
#if _LIBCPP_DEBUG_LEVEL == 2
1696-
__get_db()->swap(this, _VSTD::addressof(__u));
1695+
__get_db()->swap(this, &__u);
16971696
#endif
16981697
}
16991698

@@ -1713,7 +1712,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17131712
}
17141713
#if _LIBCPP_DEBUG_LEVEL == 2
17151714
else
1716-
__get_db()->swap(this, _VSTD::addressof(__u));
1715+
__get_db()->swap(this, &__u);
17171716
#endif
17181717
}
17191718

@@ -2469,7 +2468,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24692468
{
24702469
_VSTD::__debug_db_insert_c(this);
24712470
#if _LIBCPP_DEBUG_LEVEL == 2
2472-
__get_db()->swap(this, _VSTD::addressof(__u));
2471+
__get_db()->swap(this, &__u);
24732472
#endif
24742473
}
24752474

@@ -2490,7 +2489,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24902489
}
24912490
#if _LIBCPP_DEBUG_LEVEL == 2
24922491
else
2493-
__get_db()->swap(this, _VSTD::addressof(__u));
2492+
__get_db()->swap(this, &__u);
24942493
#endif
24952494
}
24962495

libcxx/test/std/containers/unord/unord.map/iterator.operators.addressof.compile.pass.cpp

Lines changed: 0 additions & 49 deletions
This file was deleted.

libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.addressof.compile.pass.cpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.addressof.compile.pass.cpp

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)