[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
This commit is contained in:
Chandler Carruth 2017-01-04 11:40:18 +00:00
parent 3afacf4c6f
commit d541339c25
2 changed files with 13 additions and 1 deletions

View 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;

View 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) {