<div dir="ltr">Looks good - please commit<br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 25, 2016 at 12:21 PM, Jun Bum Lim via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">junbuml updated this revision to Diff 51670.<br>
junbuml added a comment.<br>
<br>
Fixed David's comment.<br>
<div><div class="h5"><br>
<br>
<a href="http://reviews.llvm.org/D18281" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18281</a><br>
<br>
Files:<br>
  include/llvm/ADT/SetVector.h<br>
  unittests/ADT/CMakeLists.txt<br>
  unittests/ADT/SetVectorTest.cpp<br>
<br>
Index: unittests/ADT/SetVectorTest.cpp<br>
===================================================================<br>
--- /dev/null<br>
+++ unittests/ADT/SetVectorTest.cpp<br>
@@ -0,0 +1,34 @@<br>
+//===- llvm/unittest/ADT/SetVector.cpp ------------------------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// SetVector unit tests.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "llvm/ADT/SetVector.h"<br>
+#include "gtest/gtest.h"<br>
+<br>
+using namespace llvm;<br>
+<br>
+TEST(SetVector, EraseTest) {<br>
+  SetVector<int> S;<br>
+  S.insert(0);<br>
+  S.insert(1);<br>
+  S.insert(2);<br>
+<br>
+  auto I = S.erase(std::next(S.begin()));<br>
+<br>
+  // Test that the returned iterator is the expected one-after-erase<br>
+  // and the size/contents is the expected sequence {0, 2}.<br>
+  EXPECT_EQ(std::next(S.begin()), I);<br>
+  EXPECT_EQ(2u, S.size());<br>
+  EXPECT_EQ(0, *S.begin());<br>
+  EXPECT_EQ(2, *std::next(S.begin()));<br>
+}<br>
+<br>
Index: unittests/ADT/CMakeLists.txt<br>
===================================================================<br>
--- unittests/ADT/CMakeLists.txt<br>
+++ unittests/ADT/CMakeLists.txt<br>
@@ -32,6 +32,7 @@<br>
   PostOrderIteratorTest.cpp<br>
   RangeAdapterTest.cpp<br>
   SCCIteratorTest.cpp<br>
+  SetVectorTest.cpp<br>
   SmallPtrSetTest.cpp<br>
   SmallStringTest.cpp<br>
   SmallVectorTest.cpp<br>
</div></div><span class="">Index: include/llvm/ADT/SetVector.h<br>
===================================================================<br>
--- include/llvm/ADT/SetVector.h<br>
+++ include/llvm/ADT/SetVector.h<br>
</span>@@ -151,6 +151,24 @@<br>
     return false;<br>
   }<br>
<br>
+  /// Erase a single element from the set vector.<br>
<span class="">+  /// \returns an iterator pointing to the next element that followed the<br>
+  /// element erased. This is the end of the SetVector if the last element is<br>
+  /// erased.<br>
+  iterator erase(iterator I) {<br>
+    const key_type &V = *I;<br>
</span>+    assert(set_.count(V) && "Corrupted SetVector instances!");<br>
+    set_.erase(V);<br>
+<br>
<span class="">+    // FIXME: No need to use the non-const iterator when built with<br>
</span>+    // std:vector.erase(const_iterator) as defined in C++11. This is for<br>
+    // compatibility with non-standard libstdc++ up to 4.8 (fixed in 4.9).<br>
+    auto NI = vector_.begin();<br>
<span class="">+    std::advance(NI, std::distance<iterator>(NI, I));<br>
+<br>
</span>+    return vector_.erase(NI);<br>
<div class="HOEnZb"><div class="h5">+  }<br>
+<br>
   /// \brief Remove items from the set vector based on a predicate function.<br>
   ///<br>
   /// This is intended to be equivalent to the following code, if we could<br>
<br>
<br>
</div></div><br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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>
<br></blockquote></div><br></div></div>