diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 2d2279cefe5..97d1f0d1689 100644 --- a/lib/Support/FoldingSet.cpp +++ b/lib/Support/FoldingSet.cpp @@ -326,7 +326,8 @@ FoldingSetImpl::Node *FoldingSetImpl::GetOrInsertNode(FoldingSetImpl::Node *N) { FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) { // Skip to the first non-null non-self-cycle bucket. - while (*Bucket == 0 || GetNextPtr(*Bucket) == 0) + while (*Bucket != reinterpret_cast(-1) && + (*Bucket == 0 || GetNextPtr(*Bucket) == 0)) ++Bucket; NodePtr = static_cast(*Bucket); @@ -345,7 +346,8 @@ void FoldingSetIteratorImpl::advance() { // Skip to the next non-null non-self-cycle bucket. do { ++Bucket; - } while (*Bucket == 0 || GetNextPtr(*Bucket) == 0); + } while (*Bucket != reinterpret_cast(-1) && + (*Bucket == 0 || GetNextPtr(*Bucket) == 0)); NodePtr = static_cast(*Bucket); }