mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
committed by
Saleem Abdulrasool
parent
7d1da2af3d
commit
66dcad0d34
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user