summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2017-01-04 11:40:18 +0000
committerChandler Carruth <chandlerc@gmail.com>2017-01-04 11:40:18 +0000
commit2eb065035b7d06679cfebc4bb9e3434302115613 (patch)
tree5959f3e198ff812fe25e8b5eefba162d5b0aed38
parent96809ae7ea06b219cbdd2ba61c639c6067d7d652 (diff)
downloadbcm5719-llvm-2eb065035b7d06679cfebc4bb9e3434302115613.tar.gz
bcm5719-llvm-2eb065035b7d06679cfebc4bb9e3434302115613.zip
[ADT] Speculative attempt to fix build bot issues with r290952.
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... llvm-svn: 290954
-rw-r--r--llvm/include/llvm/ADT/PriorityWorklist.h6
-rw-r--r--llvm/unittests/ADT/PriorityWorklistTest.cpp8
2 files changed, 13 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/PriorityWorklist.h b/llvm/include/llvm/ADT/PriorityWorklist.h
index ef7b8930ab3..3198dd43870 100644
--- a/llvm/include/llvm/ADT/PriorityWorklist.h
+++ b/llvm/include/llvm/ADT/PriorityWorklist.h
@@ -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;
diff --git a/llvm/unittests/ADT/PriorityWorklistTest.cpp b/llvm/unittests/ADT/PriorityWorklistTest.cpp
index aa7a5430e21..040a11f95f4 100644
--- a/llvm/unittests/ADT/PriorityWorklistTest.cpp
+++ b/llvm/unittests/ADT/PriorityWorklistTest.cpp
@@ -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) {
OpenPOWER on IntegriCloud