@@ -89,6 +89,10 @@ class StringMapImpl {
8989 // / setup the map as empty.
9090 LLVM_ABI void init (unsigned Size);
9191
92+ iterator_range<StringMapEntryBase **> buckets () {
93+ return make_range (TheTable, TheTable + NumBuckets);
94+ }
95+
9296public:
9397 static constexpr uintptr_t TombstoneIntVal =
9498 static_cast <uintptr_t >(-1 )
@@ -198,8 +202,7 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
198202 // to default values. This is a copy of clear(), but avoids unnecessary
199203 // work not required in the destructor.
200204 if (!empty ()) {
201- for (unsigned I = 0 , E = NumBuckets; I != E; ++I) {
202- StringMapEntryBase *Bucket = TheTable[I];
205+ for (StringMapEntryBase *Bucket : buckets ()) {
203206 if (Bucket && Bucket != getTombstoneVal ()) {
204207 static_cast <MapEntryTy *>(Bucket)->Destroy (getAllocator ());
205208 }
@@ -398,8 +401,7 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
398401
399402 // Zap all values, resetting the keys back to non-present (not tombstone),
400403 // which is safe because we're removing all elements.
401- for (unsigned I = 0 , E = NumBuckets; I != E; ++I) {
402- StringMapEntryBase *&Bucket = TheTable[I];
404+ for (StringMapEntryBase *&Bucket : buckets ()) {
403405 if (Bucket && Bucket != getTombstoneVal ()) {
404406 static_cast <MapEntryTy *>(Bucket)->Destroy (getAllocator ());
405407 }
0 commit comments