<div dir="ltr">Hi Galina,<div><br></div><div>Thanks for the heads up. I am looking in to it now.</div><div><br></div><div>Cheers,</div><div>Lang.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 16, 2018 at 1:28 PM Galina Kistanova <<a href="mailto:gkistanova@gmail.com">gkistanova@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Hello Lang,<br><br>This commit broke build step on one of our builders:<br><a href="http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/26656" target="_blank">http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/26656</a><br><br>The builder was already red and did not send any notifications.<br><br>Please have a look?<br><br>Thanks<br><br>Galina<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 15, 2018 at 8:28 AM Lang Hames via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lhames<br>
Date: Mon Oct 15 08:26:47 2018<br>
New Revision: 344522<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=344522&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=344522&view=rev</a><br>
Log:<br>
[ADT] Adds equality operators for DenseMap and DenseSet, and an initializer_list<br>
constructor for DenseMap (DenseSet already had an initializer_list constructor).<br>
<br>
These changes make it easier to migrate existing code that uses std::map and<br>
std::set (which support initializer_list construction and equality comparison)<br>
to DenseMap and DenseSet.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/ADT/DenseMap.h<br>
    llvm/trunk/include/llvm/ADT/DenseSet.h<br>
    llvm/trunk/unittests/ADT/DenseMapTest.cpp<br>
    llvm/trunk/unittests/ADT/DenseSetTest.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/DenseMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=344522&r1=344521&r2=344522&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=344522&r1=344521&r2=344522&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Mon Oct 15 08:26:47 2018<br>
@@ -25,6 +25,7 @@<br>
 #include <cassert><br>
 #include <cstddef><br>
 #include <cstring><br>
+#include <initializer_list><br>
 #include <iterator><br>
 #include <new><br>
 #include <type_traits><br>
@@ -38,6 +39,9 @@ namespace detail {<br>
 // implementation without requiring two members.<br>
 template <typename KeyT, typename ValueT><br>
 struct DenseMapPair : public std::pair<KeyT, ValueT> {<br>
+<br>
+  using std::pair<KeyT, ValueT>::pair;<br>
+<br>
   KeyT &getFirst() { return std::pair<KeyT, ValueT>::first; }<br>
   const KeyT &getFirst() const { return std::pair<KeyT, ValueT>::first; }<br>
   ValueT &getSecond() { return std::pair<KeyT, ValueT>::second; }<br>
@@ -640,6 +644,40 @@ public:<br>
   }<br>
 };<br>
<br>
+/// Equality comparison for DenseMap.<br>
+///<br>
+/// Iterates over elements of LHS confirming that each (key, value) pair in LHS<br>
+/// is also in RHS, and that no additional pairs are in RHS.<br>
+/// Equivalent to N calls to RHS.find and N value comparisons. Amortized<br>
+/// complexity is linear, worst case is O(N^2) (if every hash collides).<br>
+template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,<br>
+          typename BucketT><br>
+bool operator==(<br>
+    const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &LHS,<br>
+    const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &RHS) {<br>
+  if (LHS.size() != RHS.size())<br>
+    return false;<br>
+<br>
+  for (auto &KV : LHS) {<br>
+    auto I = RHS.find(KV.first);<br>
+    if (I == RHS.end() || I->second != KV.second)<br>
+      return false;<br>
+  }<br>
+<br>
+  return true;<br>
+}<br>
+<br>
+/// Inequality comparison for DenseMap.<br>
+///<br>
+/// Equivalent to !(LHS == RHS). See operator== for performance notes.<br>
+template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,<br>
+          typename BucketT><br>
+bool operator!=(<br>
+    const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &LHS,<br>
+    const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &RHS) {<br>
+  return !(LHS == RHS);<br>
+}<br>
+<br>
 template <typename KeyT, typename ValueT,<br>
           typename KeyInfoT = DenseMapInfo<KeyT>,<br>
           typename BucketT = llvm::detail::DenseMapPair<KeyT, ValueT>><br>
@@ -677,6 +715,11 @@ public:<br>
     this->insert(I, E);<br>
   }<br>
<br>
+  DenseMap(std::initializer_list<typename BaseT::value_type> Vals) {<br>
+    init(Vals.size());<br>
+    this->insert(Vals.begin(), Vals.end());<br>
+  }<br>
+<br>
   ~DenseMap() {<br>
     this->destroyAll();<br>
     operator delete(Buckets);<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/DenseSet.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=344522&r1=344521&r2=344522&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=344522&r1=344521&r2=344522&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/DenseSet.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/DenseSet.h Mon Oct 15 08:26:47 2018<br>
@@ -214,6 +214,34 @@ public:<br>
   }<br>
 };<br>
<br>
+/// Equality comparison for DenseSet.<br>
+///<br>
+/// Iterates over elements of LHS confirming that each element is also a member<br>
+/// of RHS, and that RHS contains no additional values.<br>
+/// Equivalent to N calls to RHS.count. Amortized complexity is linear, worst<br>
+/// case is O(N^2) (if every hash collides).<br>
+template <typename ValueT, typename MapTy, typename ValueInfoT><br>
+bool operator==(const DenseSetImpl<ValueT, MapTy, ValueInfoT> &LHS,<br>
+                const DenseSetImpl<ValueT, MapTy, ValueInfoT> &RHS) {<br>
+  if (LHS.size() != RHS.size())<br>
+    return false;<br>
+<br>
+  for (auto &E : LHS)<br>
+    if (!RHS.count(E))<br>
+      return false;<br>
+<br>
+  return true;<br>
+}<br>
+<br>
+/// Inequality comparison for DenseSet.<br>
+///<br>
+/// Equivalent to !(LHS == RHS). See operator== for performance notes.<br>
+template <typename ValueT, typename MapTy, typename ValueInfoT><br>
+bool operator!=(const DenseSetImpl<ValueT, MapTy, ValueInfoT> &LHS,<br>
+                const DenseSetImpl<ValueT, MapTy, ValueInfoT> &RHS) {<br>
+  return !(LHS == RHS);<br>
+}<br>
+<br>
 } // end namespace detail<br>
<br>
 /// Implements a dense probed hash-table based set.<br>
<br>
Modified: llvm/trunk/unittests/ADT/DenseMapTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DenseMapTest.cpp?rev=344522&r1=344521&r2=344522&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DenseMapTest.cpp?rev=344522&r1=344521&r2=344522&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ADT/DenseMapTest.cpp (original)<br>
+++ llvm/trunk/unittests/ADT/DenseMapTest.cpp Mon Oct 15 08:26:47 2018<br>
@@ -362,6 +362,26 @@ int CountCopyAndMove::Move = 0;<br>
<br>
 } // anonymous namespace<br>
<br>
+// Test initializer list construction.<br>
+TEST(DenseMapCustomTest, InitializerList) {<br>
+  DenseMap<int, int> M({{0, 0}, {0, 1}, {1, 2}});<br>
+  EXPECT_EQ(2u, M.size());<br>
+  EXPECT_EQ(1u, M.count(0));<br>
+  EXPECT_EQ(0, M[0]);<br>
+  EXPECT_EQ(1u, M.count(1));<br>
+  EXPECT_EQ(2, M[1]);<br>
+}<br>
+<br>
+// Test initializer list construction.<br>
+TEST(DenseMapCustomTest, EqualityComparison) {<br>
+  DenseMap<int, int> M1({{0, 0}, {1, 2}});<br>
+  DenseMap<int, int> M2({{0, 0}, {1, 2}});<br>
+  DenseMap<int, int> M3({{0, 0}, {1, 3}});<br>
+<br>
+  EXPECT_EQ(M1, M2);<br>
+  EXPECT_NE(M1, M3);<br>
+}<br>
+<br>
 // Test for the default minimum size of a DenseMap<br>
 TEST(DenseMapCustomTest, DefaultMinReservedSizeTest) {<br>
   // IF THIS VALUE CHANGE, please update InitialSizeTest, InitFromIterator, and<br>
<br>
Modified: llvm/trunk/unittests/ADT/DenseSetTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DenseSetTest.cpp?rev=344522&r1=344521&r2=344522&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DenseSetTest.cpp?rev=344522&r1=344521&r2=344522&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ADT/DenseSetTest.cpp (original)<br>
+++ llvm/trunk/unittests/ADT/DenseSetTest.cpp Mon Oct 15 08:26:47 2018<br>
@@ -121,6 +121,15 @@ TYPED_TEST(DenseSetTest, FindAsTest) {<br>
   EXPECT_TRUE(set.find_as("d") == set.end());<br>
 }<br>
<br>
+TYPED_TEST(DenseSetTest, EqualityComparisonTest) {<br>
+  TypeParam set1({1, 2, 3, 4});<br>
+  TypeParam set2({4, 3, 2, 1});<br>
+  TypeParam set3({2, 3, 4, 5});<br>
+<br>
+  EXPECT_EQ(set1, set2);<br>
+  EXPECT_NE(set1, set3);<br>
+}<br>
+<br>
 // Simple class that counts how many moves and copy happens when growing a map<br>
 struct CountCopyAndMove {<br>
   static int Move;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</blockquote></div>