Index: lldb/trunk/source/Utility/Scalar.cpp =================================================================== --- lldb/trunk/source/Utility/Scalar.cpp +++ lldb/trunk/source/Utility/Scalar.cpp @@ -2598,37 +2598,7 @@ } bool lldb_private::operator!=(const Scalar &lhs, const Scalar &rhs) { - // If either entry is void then we can just compare the types - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return lhs.m_type != rhs.m_type; - - Scalar - temp_value; // A temp value that might get a copy of either promoted value - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - return a->m_integer != b->m_integer; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result != llvm::APFloat::cmpEqual) - return true; - } - return true; + return !(lhs == rhs); } bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) { Index: lldb/trunk/unittests/Utility/ScalarTest.cpp =================================================================== --- lldb/trunk/unittests/Utility/ScalarTest.cpp +++ lldb/trunk/unittests/Utility/ScalarTest.cpp @@ -19,6 +19,33 @@ using namespace lldb_private; using namespace llvm; +template +bool checkInequality(T c1, T c2) { + return (Scalar(c1) != Scalar(c2)); +} + +template +bool checkEquality(T c1, T c2) { + return (Scalar(c1) == Scalar(c2)); +} + +TEST(ScalarTest, Equality) { + ASSERT_TRUE(checkInequality(23, 24)); + ASSERT_TRUE(checkEquality(96, 96)); + ASSERT_TRUE(checkInequality(4.0f, 4.5f)); + ASSERT_TRUE(checkEquality(4.0f, 4.0f)); + uint64_t apint1 = 234; + uint64_t apint2 = 246; + ASSERT_TRUE(checkInequality(APInt(64, apint1), APInt(64, apint2))); + ASSERT_TRUE(checkEquality(APInt(64, apint1), APInt(64, apint1))); + + Scalar void1; + Scalar void2; + float f1 = 2.0; + ASSERT_TRUE(void1 == void2); + ASSERT_FALSE(void1 == Scalar(f1)); +} + TEST(ScalarTest, RightShiftOperator) { int a = 0x00001000; int b = 0xFFFFFFFF;