[libcxx] r187659 - debug mode for unordered_map. Also picked up a missing check and test in unordered_multimap. This wraps up debug mode for the unordered containers.

Howard Hinnant hhinnant at apple.com
Fri Aug 2 10:50:50 PDT 2013


Author: hhinnant
Date: Fri Aug  2 12:50:49 2013
New Revision: 187659

URL: http://llvm.org/viewvc/llvm-project?rev=187659&view=rev
Log:
debug mode for unordered_map.  Also picked up a missing check and test in unordered_multimap.  This wraps up debug mode for the unordered containers.

Added:
    libcxx/trunk/test/containers/unord/unord.map/db_iterators_7.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/db_iterators_8.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
Modified:
    libcxx/trunk/include/__debug
    libcxx/trunk/include/__hash_table
    libcxx/trunk/test/containers/unord/unord.map/bucket.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/bucket_size.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/max_load_factor.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
    libcxx/trunk/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
    libcxx/trunk/www/debug_mode.html

Modified: libcxx/trunk/include/__debug
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__debug?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/include/__debug (original)
+++ libcxx/trunk/include/__debug Fri Aug  2 12:50:49 2013
@@ -24,6 +24,10 @@
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 struct _LIBCPP_TYPE_VIS __c_node;

Modified: libcxx/trunk/include/__hash_table
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Aug  2 12:50:49 2013
@@ -1714,6 +1714,11 @@ typename __hash_table<_Tp, _Hash, _Equal
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
         const_iterator __p, __node_pointer __cp)
 {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
+        " referring to this unordered container");
+#endif
     if (__p != end() && key_eq()(*__p, __cp->__value_))
     {
         __node_pointer __np = __p.__node_;

Modified: libcxx/trunk/test/containers/unord/unord.map/bucket.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/bucket.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/bucket.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/bucket.pass.cpp Fri Aug  2 12:50:49 2013
@@ -15,6 +15,10 @@
 
 // size_type bucket(const key_type& __k) const;
 
+#ifdef _LIBCPP_DEBUG2
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <unordered_map>
 #include <string>
 #include <cassert>
@@ -62,4 +66,12 @@ int main()
             assert(c.bucket(i) == i % bc);
     }
 #endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_map<int, std::string> C;
+        C c;
+        C::size_type i = c.bucket(3);
+        assert(false);
+    }
+#endif
 }

Modified: libcxx/trunk/test/containers/unord/unord.map/bucket_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/bucket_size.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/bucket_size.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/bucket_size.pass.cpp Fri Aug  2 12:50:49 2013
@@ -15,6 +15,10 @@
 
 // size_type bucket_size(size_type n) const
 
+#ifdef _LIBCPP_DEBUG2
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <unordered_map>
 #include <string>
 #include <cassert>
@@ -66,4 +70,12 @@ int main()
         assert(c.bucket_size(4) == 1);
     }
 #endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_map<int, std::string> C;
+        C c;
+        C::size_type i = c.bucket_size(3);
+        assert(false);
+    }
+#endif
 }

Added: libcxx/trunk/test/containers/unord/unord.map/db_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/db_iterators_7.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/db_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/db_iterators_7.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "../../min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/db_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/db_iterators_8.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/db_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/db_iterators_8.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "../../min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.end();
+    C::value_type j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.end();
+    C::value_type j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "../../min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "../../min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    C::value_type j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    C::value_type j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Modified: libcxx/trunk/test/containers/unord/unord.map/max_load_factor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/max_load_factor.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/max_load_factor.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/max_load_factor.pass.cpp Fri Aug  2 12:50:49 2013
@@ -16,6 +16,10 @@
 // float max_load_factor() const;
 // void max_load_factor(float mlf);
 
+#ifdef _LIBCPP_DEBUG2
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <unordered_map>
 #include <string>
 #include <cassert>
@@ -56,4 +60,12 @@ int main()
         assert(c.max_load_factor() == 2.5);
     }
 #endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_map<int, std::string> C;
+        C c;
+        c.max_load_factor(0);
+        assert(false);
+    }
+#endif
 }

Modified: libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp Fri Aug  2 12:50:49 2013
@@ -213,5 +213,17 @@ int main()
         assert(c0.size() == 0);
     }
 #endif
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+        std::unordered_map<int, int>::iterator i = s1.begin();
+        std::pair<const int, int> k = *i;
+        std::unordered_map<int, int> s2;
+        s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Modified: libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp Fri Aug  2 12:50:49 2013
@@ -184,5 +184,16 @@ int main()
         assert(c0.empty());
     }
 #endif
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+        std::unordered_map<int, int>::iterator i = s1.begin();
+        std::pair<const int, int> k = *i;
+        std::unordered_map<int, int> s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Added: libcxx/trunk/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_map
+
+// void swap(unordered_map& x, unordered_map& y);
+
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        typedef std::pair<int, int> P;
+        P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+        P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+        std::unordered_map<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::unordered_map<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::unordered_map<int, int>::iterator i1 = c1.begin();
+        std::unordered_map<int, int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        std::unordered_map<int, int>::iterator j = i1;
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+}

Modified: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp Fri Aug  2 12:50:49 2013
@@ -16,6 +16,10 @@
 // template <class... Args>
 //     iterator emplace_hint(const_iterator p, Args&&... args);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <unordered_map>
 #include <cassert>
 
@@ -72,5 +76,18 @@ int main()
         assert(r->second == Emplaceable(6, 7));
     }
 #endif
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(3),
+                                       std::forward_as_tuple());
+        assert(false);
+    }
+#endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Added: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Added: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp?rev=187659&view=auto
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp (added)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp Fri Aug  2 12:50:49 2013
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG2 >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif

Modified: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp Fri Aug  2 12:50:49 2013
@@ -15,6 +15,10 @@
 
 // iterator insert(const_iterator p, const value_type& x);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <unordered_map>
 #include <cassert>
 
@@ -77,4 +81,17 @@ int main()
         assert(r->second == 4);
     }
 #endif
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        P v(3.5, 3);
+        R r = c.insert(e, v);
+        assert(false);
+    }
+#endif
 }

Modified: libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp Fri Aug  2 12:50:49 2013
@@ -17,6 +17,10 @@
 //           class = typename enable_if<is_convertible<P, value_type>::value>::type>
 //     iterator insert(const_iterator p, P&& x);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <unordered_map>
 #include <cassert>
 
@@ -136,5 +140,17 @@ int main()
         assert(r->second == 4);
     }
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(false);
+    }
+#endif
 #endif
 }

Modified: libcxx/trunk/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp Fri Aug  2 12:50:49 2013
@@ -16,6 +16,10 @@
 // template <class... Args>
 //     iterator emplace_hint(const_iterator p, Args&&... args);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <unordered_map>
 #include <cassert>
 
@@ -88,5 +92,18 @@ int main()
         assert(r->second == Emplaceable(5, 6));
     }
 #endif
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        typedef std::unordered_multimap<int, Emplaceable> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(3),
+                                       std::forward_as_tuple());
+        assert(false);
+    }
+#endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Modified: libcxx/trunk/www/debug_mode.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/debug_mode.html?rev=187659&r1=187658&r2=187659&view=diff
==============================================================================
--- libcxx/trunk/www/debug_mode.html (original)
+++ libcxx/trunk/www/debug_mode.html Fri Aug  2 12:50:49 2013
@@ -50,7 +50,7 @@ record which parts of libc++ have debug
 <code><unordered_map></code>
 </p>
 </td>
-<td align="center"><!-- ✓ --></td>
+<td align="center"> ✓ </td>
 </tr>
 
 <tr>





More information about the cfe-commits mailing list