SIL: Avoid dereferencing sentinel nodes in ilist_iterators

The behaviour of ilist has changed in LLVM.  It is no longer permissible to
dereference the `end()` value.  Add a check to ensure that we do not
accidentally dereference the iterator.
This commit is contained in:
Francis Ricci
2016-10-05 17:10:41 -07:00
committed by Saleem Abdulrasool
parent 7d1da2af3d
commit 66dcad0d34
8 changed files with 45 additions and 37 deletions

View File

@@ -180,6 +180,14 @@ inline void set_union_for_each(const Container1 &C1, const Container2 &C2,
set_union_for_each(C1.begin(), C1.end(), C2.begin(), C2.end(), f);
}
/// Takes an iterator and an iterator pointing to the end of the iterator range.
/// If the iterator already points to the end of its range, simply return it,
/// otherwise return the the next element.
template <typename Iterator>
inline Iterator next_or_end(Iterator it, Iterator end) {
return (it == end) ? end : std::next(it);
}
/// @}
/// A range of iterators.