ADT: Avoid using std::equal in ArrayRef::equals

MSVC's STL has a bug in `std::equal()`: it asserts on nullptr iterators,
causing a block revert in r215981.  This works around that by re-writing
`ArrayRef::equals()` to do the work itself.

llvm-svn: 215986
This commit is contained in:
Duncan P. N. Exon Smith 2014-08-19 16:36:21 +00:00
parent ca39572270
commit 16bec8e667
1 changed files with 7 additions and 1 deletions

View File

@ -145,7 +145,13 @@ namespace llvm {
bool equals(ArrayRef RHS) const {
if (Length != RHS.Length)
return false;
return std::equal(begin(), end(), RHS.begin());
// Don't use std::equal(), since it asserts in MSVC on nullptr iterators.
for (auto L = begin(), LE = end(), R = RHS.begin(); L != LE; ++L, ++R)
// Match std::equal() in using == (instead of !=) to minimize API
// requirements of ArrayRef'ed types.
if (!(*L == *R))
return false;
return true;
}
/// slice(n) - Chop off the first N elements of the array.