[libcxx-commits] [libcxx] bc4d3ca - [libcxx] Use integer division

Petr Hosek via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 29 11:59:54 PDT 2021


Author: Petr Hosek
Date: 2021-03-29T11:59:44-07:00
New Revision: bc4d3ca7bd4401daafc22747ed952208cf18cba9

URL: https://github.com/llvm/llvm-project/commit/bc4d3ca7bd4401daafc22747ed952208cf18cba9
DIFF: https://github.com/llvm/llvm-project/commit/bc4d3ca7bd4401daafc22747ed952208cf18cba9.diff

LOG: [libcxx] Use integer division

In Python 3, math.floor returns int when both arguments are ints.
In Python 2, math.floor returns float. This leads to a failure
because the result of math.floor is used as an array index. While
Python 2 is on its way out, it's still used in some places so use
an integer division instead.

Differential Revision: https://reviews.llvm.org/D99520

Added: 
    

Modified: 
    libcxx/utils/gdb/libcxx/printers.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/gdb/libcxx/printers.py b/libcxx/utils/gdb/libcxx/printers.py
index 9b413a86b1597..1e88e1e7049ea 100644
--- a/libcxx/utils/gdb/libcxx/printers.py
+++ b/libcxx/utils/gdb/libcxx/printers.py
@@ -439,7 +439,7 @@ def to_string(self):
 
     def _list_it(self):
         for bit in range(self.bit_count):
-            word = math.floor(bit / self.bits_per_word)
+            word = bit // self.bits_per_word
             word_bit = bit % self.bits_per_word
             if self.values[word] & (1 << word_bit):
                 yield ("[%d]" % bit, 1)


        


More information about the libcxx-commits mailing list