@@ -224,7 +224,7 @@ ThreadSafeTrieRawHashMapBase::find(ArrayRef<uint8_t> Hash) const {
224224 TrieSubtrie *S = &Impl->Root ;
225225 IndexGenerator IndexGen{NumRootBits, NumSubtrieBits, Hash};
226226 size_t Index = IndexGen.next ();
227- while (true ) {
227+ while (Index != IndexGen. end () ) {
228228 // Try to set the content.
229229 TrieNode *Existing = S->get (Index);
230230 if (!Existing)
@@ -239,6 +239,7 @@ ThreadSafeTrieRawHashMapBase::find(ArrayRef<uint8_t> Hash) const {
239239 Index = IndexGen.next ();
240240 S = cast<TrieSubtrie>(Existing);
241241 }
242+ llvm_unreachable (" failed to locate the node after consuming all hash bytes" );
242243}
243244
244245ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert (
@@ -258,7 +259,7 @@ ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert(
258259 Index = IndexGen.next ();
259260 }
260261
261- while (true ) {
262+ while (Index != IndexGen. end () ) {
262263 // Load the node from the slot, allocating and calling the constructor if
263264 // the slot is empty.
264265 bool Generated = false ;
@@ -292,8 +293,8 @@ ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert(
292293 return PointerBase (ExistingContent.getValuePointer ());
293294
294295 // Sink the existing content as long as the indexes match.
295- while ( true ) {
296- size_t NextIndex = IndexGen.next ();
296+ size_t NextIndex = IndexGen. next ();
297+ while ( NextIndex ! = IndexGen.end ()) {
297298 size_t NewIndexForExistingContent =
298299 IndexGen.getCollidingBits (ExistingContent.getHash ());
299300 S = S->sink (Index, ExistingContent, IndexGen.getNumBits (),
@@ -306,8 +307,11 @@ ThreadSafeTrieRawHashMapBase::PointerBase ThreadSafeTrieRawHashMapBase::insert(
306307 // Found the difference.
307308 if (NextIndex != NewIndexForExistingContent)
308309 break ;
310+
311+ NextIndex = IndexGen.next ();
309312 }
310313 }
314+ llvm_unreachable (" failed to insert the node after consuming all hash bytes" );
311315}
312316
313317ThreadSafeTrieRawHashMapBase::ThreadSafeTrieRawHashMapBase (
0 commit comments