summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2018-03-27 18:37:54 +0000
committerDavide Italiano <davide@freebsd.org>2018-03-27 18:37:54 +0000
commit01c33b818950af40a7bd2089211a24db8c1f7dd0 (patch)
treeb2878af68d35f15ad90b83764badd2c86b1c25d8
parent0375cd46ef31c026e3346716f4af1ffbf675a1f6 (diff)
downloadbcm5719-llvm-01c33b818950af40a7bd2089211a24db8c1f7dd0.tar.gz
bcm5719-llvm-01c33b818950af40a7bd2089211a24db8c1f7dd0.zip
[Core] Correctly handle float division in Scalar.
Patch by Tom Tromey! Differential Revision: https://reviews.llvm.org/D44693 llvm-svn: 328649
-rw-r--r--lldb/source/Core/Scalar.cpp2
-rw-r--r--lldb/unittests/Core/ScalarTest.cpp8
2 files changed, 9 insertions, 1 deletions
diff --git a/lldb/source/Core/Scalar.cpp b/lldb/source/Core/Scalar.cpp
index 630083bae93..4ef29e75b3d 100644
--- a/lldb/source/Core/Scalar.cpp
+++ b/lldb/source/Core/Scalar.cpp
@@ -2266,7 +2266,7 @@ const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) {
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;
}
diff --git a/lldb/unittests/Core/ScalarTest.cpp b/lldb/unittests/Core/ScalarTest.cpp
index fedcd195e4a..47fa0215ead 100644
--- a/lldb/unittests/Core/ScalarTest.cpp
+++ b/lldb/unittests/Core/ScalarTest.cpp
@@ -132,3 +132,11 @@ TEST(ScalarTest, GetValue) {
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));
+}
OpenPOWER on IntegriCloud