summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-08-19 16:36:21 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-08-19 16:36:21 +0000
commit16bec8e667cf21a69622a4a440f5b196f3c8ff3b (patch)
tree943f3debb7f9c4daed699ad524a2bb6f292140dc
parentca3957227084d3a0b16bdfeff889a61e7c33bb01 (diff)
downloadbcm5719-llvm-16bec8e667cf21a69622a4a440f5b196f3c8ff3b.tar.gz
bcm5719-llvm-16bec8e667cf21a69622a4a440f5b196f3c8ff3b.zip
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
-rw-r--r--llvm/include/llvm/ADT/ArrayRef.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index 44400d591da..0351cf5bb4c 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -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.
OpenPOWER on IntegriCloud