This revision was automatically updated to reflect the committed changes. Closed by commit rL328649: [Core] Correctly handle float division in Scalar. (authored by davide, committed by ). Herald added a subscriber: llvm-commits.
Repository: rL LLVM https://reviews.llvm.org/D44693 Files: lldb/trunk/source/Core/Scalar.cpp lldb/trunk/unittests/Core/ScalarTest.cpp Index: lldb/trunk/unittests/Core/ScalarTest.cpp =================================================================== --- lldb/trunk/unittests/Core/ScalarTest.cpp +++ lldb/trunk/unittests/Core/ScalarTest.cpp @@ -132,3 +132,11 @@ EXPECT_EQ(std::to_string(std::numeric_limits<unsigned long long>::max()), ScalarGetValue(std::numeric_limits<unsigned long long>::max())); } + +TEST(ScalarTest, Division) { + Scalar lhs(5.0); + Scalar rhs(2.0); + Scalar r = lhs / rhs; + EXPECT_TRUE(r.IsValid()); + EXPECT_EQ(r, Scalar(2.5)); +} Index: lldb/trunk/source/Core/Scalar.cpp =================================================================== --- lldb/trunk/source/Core/Scalar.cpp +++ lldb/trunk/source/Core/Scalar.cpp @@ -2266,7 +2266,7 @@ case Scalar::e_float: case Scalar::e_double: case Scalar::e_long_double: - if (b->m_float.isZero()) { + if (!b->m_float.isZero()) { result.m_float = a->m_float / b->m_float; return result; }
Index: lldb/trunk/unittests/Core/ScalarTest.cpp =================================================================== --- lldb/trunk/unittests/Core/ScalarTest.cpp +++ lldb/trunk/unittests/Core/ScalarTest.cpp @@ -132,3 +132,11 @@ EXPECT_EQ(std::to_string(std::numeric_limits<unsigned long long>::max()), ScalarGetValue(std::numeric_limits<unsigned long long>::max())); } + +TEST(ScalarTest, Division) { + Scalar lhs(5.0); + Scalar rhs(2.0); + Scalar r = lhs / rhs; + EXPECT_TRUE(r.IsValid()); + EXPECT_EQ(r, Scalar(2.5)); +} Index: lldb/trunk/source/Core/Scalar.cpp =================================================================== --- lldb/trunk/source/Core/Scalar.cpp +++ lldb/trunk/source/Core/Scalar.cpp @@ -2266,7 +2266,7 @@ case Scalar::e_float: case Scalar::e_double: case Scalar::e_long_double: - if (b->m_float.isZero()) { + if (!b->m_float.isZero()) { result.m_float = a->m_float / b->m_float; return result; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits