[PATCH] D60198: [TextAPI] Fix off-by-one error in the bit index extraction loop

Petar Jovanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 05:57:34 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL357759: [TextAPI] Fix off-by-one error in the bit index extraction loop (authored by petarj, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D60198?vs=193478&id=193860#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60198/new/

https://reviews.llvm.org/D60198

Files:
  llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h


Index: llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h
===================================================================
--- llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h
+++ llvm/trunk/include/llvm/TextAPI/MachO/ArchitectureSet.h
@@ -69,11 +69,10 @@
     void findNextSetBit() {
       if (Index == EndIndexVal)
         return;
-
-      do {
-        if (*ArchSet & (1UL << ++Index))
+      while (++Index < sizeof(Ty) * 8) {
+        if (*ArchSet & (1UL << Index))
           return;
-      } while (Index < sizeof(Ty) * 8);
+      }
 
       Index = EndIndexVal;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60198.193860.patch
Type: text/x-patch
Size: 594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190405/7e27c546/attachment.bin>


More information about the llvm-commits mailing list