Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

A conventional "if" statement is easier to read than the
do-while(false) pattern used here.

A conventional "if" statement is easier to read than the
do-while(false) pattern used here.
@llvmbot
Copy link
Member

llvmbot commented Oct 26, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

A conventional "if" statement is easier to read than the
do-while(false) pattern used here.


Full diff: https://github.com/llvm/llvm-project/pull/165133.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/ImmutableSet.h (+1-4)
diff --git a/llvm/include/llvm/ADT/ImmutableSet.h b/llvm/include/llvm/ADT/ImmutableSet.h
index 8b2425e4e8fef..1b40dac4d092c 100644
--- a/llvm/include/llvm/ADT/ImmutableSet.h
+++ b/llvm/include/llvm/ADT/ImmutableSet.h
@@ -635,9 +635,7 @@ class ImutAVLFactory {
     // if find a collision compare those trees by their contents.
     unsigned digest = TNew->computeDigest();
     TreeTy *&entry = Cache[maskCacheIndex(digest)];
-    do {
-      if (!entry)
-        break;
+    if (entry) {
       for (TreeTy *T = entry ; T != nullptr; T = T->next) {
         // Compare the Contents('T') with Contents('TNew')
         typename TreeTy::iterator TI = T->begin(), TE = T->end();
@@ -653,7 +651,6 @@ class ImutAVLFactory {
       entry->prev = TNew;
       TNew->next = entry;
     }
-    while (false);
 
     entry = TNew;
     TNew->IsCanonicalized = true;

@kazutakahirata kazutakahirata merged commit 3ebc935 into llvm:main Oct 26, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251025_ADT_ImmutableSet branch October 26, 2025 15:20
varun-r-mallya pushed a commit to varun-r-mallya/llvm-project that referenced this pull request Oct 27, 2025
A conventional "if" statement is easier to read than the
do-while(false) pattern used here.
dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
A conventional "if" statement is easier to read than the
do-while(false) pattern used here.
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
A conventional "if" statement is easier to read than the
do-while(false) pattern used here.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
A conventional "if" statement is easier to read than the
do-while(false) pattern used here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants