Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit c71c249

Browse files
dccitromey
authored andcommitted
[Core] Correctly handle float division in Scalar.
Patch by Tom Tromey! Differential Revision: https://reviews.llvm.org/D44693 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@328649 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b6df24f commit c71c249

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

source/Core/Scalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) {
22662266
case Scalar::e_float:
22672267
case Scalar::e_double:
22682268
case Scalar::e_long_double:
2269-
if (b->m_float.isZero()) {
2269+
if (!b->m_float.isZero()) {
22702270
result.m_float = a->m_float / b->m_float;
22712271
return result;
22722272
}

unittests/Core/ScalarTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,11 @@ TEST(ScalarTest, GetValue) {
132132
EXPECT_EQ(std::to_string(std::numeric_limits<unsigned long long>::max()),
133133
ScalarGetValue(std::numeric_limits<unsigned long long>::max()));
134134
}
135+
136+
TEST(ScalarTest, Division) {
137+
Scalar lhs(5.0);
138+
Scalar rhs(2.0);
139+
Scalar r = lhs / rhs;
140+
EXPECT_TRUE(r.IsValid());
141+
EXPECT_EQ(r, Scalar(2.5));
142+
}

0 commit comments

Comments
 (0)