diff options
author | Galina Kistanova <gkistanova@gmail.com> | 2018-07-12 17:58:10 +0000 |
---|---|---|
committer | Galina Kistanova <gkistanova@gmail.com> | 2018-07-12 17:58:10 +0000 |
commit | 82cebf952ef8dfc8156d32406ddad38c1fbb60dc (patch) | |
tree | 9e7b9838b703604932bf6ebc7f05b05fb61a1932 | |
parent | 8217a2ab4faf0f50dde8fb79b04df77324845255 (diff) | |
download | bcm5719-llvm-82cebf952ef8dfc8156d32406ddad38c1fbb60dc.tar.gz bcm5719-llvm-82cebf952ef8dfc8156d32406ddad38c1fbb60dc.zip |
Reverted r336805 as it broke llvm-clang-x86_64-expensive-checks-win build bot
llvm-svn: 336923
-rw-r--r-- | llvm/include/llvm/ADT/SmallSet.h | 67 | ||||
-rw-r--r-- | llvm/unittests/ADT/SmallSetTest.cpp | 55 |
2 files changed, 0 insertions, 122 deletions
diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h index 8c45f76b3b5..d52d0f07f9a 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h @@ -17,68 +17,14 @@ #include "llvm/ADT/None.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/iterator.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/type_traits.h" #include <cstddef> #include <functional> #include <set> -#include <type_traits> #include <utility> namespace llvm { -/// SmallSetIterator - This class implements a const_iterator for SmallSet by -/// delegating to the underlying SmallVector or Set iterators. -template <typename T, unsigned N, typename C> -class SmallSetIterator - : public iterator_facade_base<SmallSetIterator<T, N, C>, - std::forward_iterator_tag, T> { -private: - using SetIterTy = typename std::set<T, C>::const_iterator; - using VecIterTy = typename SmallVector<T, N>::const_iterator; - using SelfTy = SmallSetIterator<T, N, C>; - - /// Iterators to the parts of the SmallSet containing the data. They are set - /// depending on isSmall. - union { - SetIterTy SetIter; - VecIterTy VecIter; - }; - - bool isSmall; - -public: - SmallSetIterator(SetIterTy SetIter) : SetIter(SetIter), isSmall(false) { - // Use static_assert here, as the SmallSetIterator type is incomplete in the - // class scope. - static_assert(std::is_trivially_destructible<SelfTy>() && - llvm::is_trivially_copy_constructible<SelfTy>() && - llvm::is_trivially_move_constructible<SelfTy>(), - "SelfTy needs to by trivially constructible and destructible"); - } - - SmallSetIterator(VecIterTy VecIter) : VecIter(VecIter), isSmall(true) {} - - bool operator==(const SmallSetIterator &RHS) const { - if (isSmall != RHS.isSmall) - return false; - if (isSmall) - return VecIter == RHS.VecIter; - return SetIter == RHS.SetIter; - } - - SmallSetIterator &operator++() { // Preincrement - if (isSmall) - VecIter++; - else - SetIter++; - return *this; - } - - const T &operator*() const { return isSmall ? *VecIter : *SetIter; } -}; - /// SmallSet - This maintains a set of unique values, optimizing for the case /// when the set is small (less than N). In this case, the set can be /// maintained with no mallocs. If the set gets large, we expand to using an @@ -104,7 +50,6 @@ class SmallSet { public: using size_type = size_t; - using const_iterator = SmallSetIterator<T, N, C>; SmallSet() = default; @@ -176,18 +121,6 @@ public: Set.clear(); } - const_iterator begin() const { - if (isSmall()) - return {Vector.begin()}; - return {Set.begin()}; - } - - const_iterator end() const { - if (isSmall()) - return {Vector.end()}; - return {Set.end()}; - } - private: bool isSmall() const { return Set.empty(); } diff --git a/llvm/unittests/ADT/SmallSetTest.cpp b/llvm/unittests/ADT/SmallSetTest.cpp index f820c9e5ccf..7608e65674e 100644 --- a/llvm/unittests/ADT/SmallSetTest.cpp +++ b/llvm/unittests/ADT/SmallSetTest.cpp @@ -13,7 +13,6 @@ #include "llvm/ADT/SmallSet.h" #include "gtest/gtest.h" -#include <string> using namespace llvm; @@ -69,57 +68,3 @@ TEST(SmallSetTest, Erase) { EXPECT_EQ(0u, s1.count(8)); } - -TEST(SmallSetTest, IteratorInt) { - SmallSet<int, 4> s1; - - // Test the 'small' case. - for (int i = 0; i < 3; i++) - s1.insert(i); - - std::vector<int> V(s1.begin(), s1.end()); - // Make sure the elements are in the expected order. - std::sort(V.begin(), V.end()); - for (int i = 0; i < 3; i++) - EXPECT_EQ(i, V[i]); - - // Test the 'big' case by adding a few more elements to switch to std::set - // internally. - for (int i = 3; i < 6; i++) - s1.insert(i); - - V.assign(s1.begin(), s1.end()); - // Make sure the elements are in the expected order. - std::sort(V.begin(), V.end()); - for (int i = 0; i < 6; i++) - EXPECT_EQ(i, V[i]); -} - -TEST(SmallSetTest, IteratorString) { - // Test SmallSetIterator for SmallSet with a type with non-trivial - // ctors/dtors. - SmallSet<std::string, 2> s1; - - s1.insert("str 1"); - s1.insert("str 2"); - s1.insert("str 1"); - - std::vector<std::string> V(s1.begin(), s1.end()); - std::sort(V.begin(), V.end()); - EXPECT_EQ(2u, s1.size()); - EXPECT_EQ("str 1", V[0]); - EXPECT_EQ("str 2", V[1]); - - s1.insert("str 4"); - s1.insert("str 0"); - s1.insert("str 4"); - - V.assign(s1.begin(), s1.end()); - // Make sure the elements are in the expected order. - std::sort(V.begin(), V.end()); - EXPECT_EQ(4u, s1.size()); - EXPECT_EQ("str 0", V[0]); - EXPECT_EQ("str 1", V[1]); - EXPECT_EQ("str 2", V[2]); - EXPECT_EQ("str 4", V[3]); -} |