From: Eli Friedman Date: Sat, 11 Apr 2020 21:53:09 +0000 (-0700) Subject: [DenseMap] Add assertion that end() iterator isn't derefenced. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e86e5eedc684453fe0af6eca2ebdbff33db012c;p=platform%2Fupstream%2Fllvm.git [DenseMap] Add assertion that end() iterator isn't derefenced. This would have saved me some time this morning. --- diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index b73afae..8d83f7e 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -1201,12 +1201,14 @@ public: reference operator*() const { assert(isHandleInSync() && "invalid iterator access!"); + assert(Ptr != End && "dereferencing end() iterator"); if (shouldReverseIterate()) return Ptr[-1]; return *Ptr; } pointer operator->() const { assert(isHandleInSync() && "invalid iterator access!"); + assert(Ptr != End && "dereferencing end() iterator"); if (shouldReverseIterate()) return &(Ptr[-1]); return Ptr; @@ -1229,6 +1231,7 @@ public: inline DenseMapIterator& operator++() { // Preincrement assert(isHandleInSync() && "invalid iterator access!"); + assert(Ptr != End && "incrementing end() iterator"); if (shouldReverseIterate()) { --Ptr; RetreatPastEmptyBuckets();