llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Ilia Kuklin (kuilpd) <details> <summary>Changes</summary> Right shift operator in `Scalar` didn't check if the value is unsigned to perform a logical right shift. Use the right shift operator from `APSInt` that does this check. --- Full diff: https://github.com/llvm/llvm-project/pull/160149.diff 2 Files Affected: - (modified) lldb/source/Utility/Scalar.cpp (+3-17) - (modified) lldb/unittests/Utility/ScalarTest.cpp (+3) ``````````diff diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp index c8766bdf2aee7..f2c18cdd896da 100644 --- a/lldb/source/Utility/Scalar.cpp +++ b/lldb/source/Utility/Scalar.cpp @@ -471,24 +471,10 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) { } Scalar &Scalar::operator>>=(const Scalar &rhs) { - switch (m_type) { - case e_void: - case e_float: + if (m_type == e_int && rhs.m_type == e_int) + m_integer >>= rhs.m_integer.getZExtValue(); + else m_type = e_void; - break; - - case e_int: - switch (rhs.m_type) { - case e_void: - case e_float: - m_type = e_void; - break; - case e_int: - m_integer = m_integer.ashr(rhs.m_integer); - break; - } - break; - } return *this; } diff --git a/lldb/unittests/Utility/ScalarTest.cpp b/lldb/unittests/Utility/ScalarTest.cpp index 6d5caef42bee4..e6d7479b59fee 100644 --- a/lldb/unittests/Utility/ScalarTest.cpp +++ b/lldb/unittests/Utility/ScalarTest.cpp @@ -118,11 +118,14 @@ TEST(ScalarTest, RightShiftOperator) { int a = 0x00001000; int b = 0xFFFFFFFF; int c = 4; + unsigned d = 0xFFFFFFFF; Scalar a_scalar(a); Scalar b_scalar(b); Scalar c_scalar(c); + Scalar d_scalar(d); ASSERT_EQ(a >> c, a_scalar >> c_scalar); ASSERT_EQ(b >> c, b_scalar >> c_scalar); + ASSERT_EQ(d >> c, d_scalar >> c_scalar); } TEST(ScalarTest, GetBytes) { `````````` </details> https://github.com/llvm/llvm-project/pull/160149 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits