OSDN Git Service

[ADT] Speculative attempt to fix build bot issues with r290952.
authorChandler Carruth <chandlerc@gmail.com>
Wed, 4 Jan 2017 11:40:18 +0000 (11:40 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 4 Jan 2017 11:40:18 +0000 (11:40 +0000)
This just removes the usage of llvm::reverse and llvm::seq. That makes
it harder to handle the empty case correctly and so I've also added
a test there.

This is just a shot in the dark at what might be behind the buildbot
failures. I can't reproduce any issues locally including with ASan...
I feel like I'm missing something...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290954 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/PriorityWorklist.h
unittests/ADT/PriorityWorklistTest.cpp

index ef7b893..3198dd4 100644 (file)
@@ -112,12 +112,16 @@ public:
   template <typename SequenceT>
   typename std::enable_if<!std::is_convertible<SequenceT, T>::value>::type
   insert(SequenceT &&Input) {
+    if (std::begin(Input) == std::end(Input))
+      // Nothing to do for an empty input sequence.
+      return;
+
     // First pull the input sequence into the vector as a bulk append
     // operation.
     ptrdiff_t StartIndex = V.size();
     V.insert(V.end(), std::begin(Input), std::end(Input));
     // Now walk backwards fixing up the index map and deleting any duplicates.
-    for (auto i : reverse(seq<ptrdiff_t>(StartIndex, V.size()))) {
+    for (ptrdiff_t i = V.size() - 1; i >= StartIndex; --i) {
       auto InsertResult = M.insert({V[i], i});
       if (InsertResult.second)
         continue;
index aa7a543..040a11f 100644 (file)
@@ -109,6 +109,14 @@ TYPED_TEST(PriorityWorklistTest, InsertSequence) {
   EXPECT_EQ(7, W.pop_back_val());
   EXPECT_EQ(2, W.pop_back_val());
   ASSERT_TRUE(W.empty());
+
+  ASSERT_TRUE(W.insert(2));
+  ASSERT_TRUE(W.insert(7));
+  // Inserting an empty sequence does nothing.
+  W.insert(std::vector<int>());
+  EXPECT_EQ(7, W.pop_back_val());
+  EXPECT_EQ(2, W.pop_back_val());
+  ASSERT_TRUE(W.empty());
 }
 
 TYPED_TEST(PriorityWorklistTest, EraseIf) {