[Lldb-commits] [lldb] 798644e - [Scalar] Fix assignment operator for long long.
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 3 04:26:33 PDT 2020
Author: Andy Yankovsky
Date: 2020-06-03T13:26:25+02:00
New Revision: 798644e0a4524e73e1f95202951f10f2086217c3
URL: https://github.com/llvm/llvm-project/commit/798644e0a4524e73e1f95202951f10f2086217c3
DIFF: https://github.com/llvm/llvm-project/commit/798644e0a4524e73e1f95202951f10f2086217c3.diff
LOG: [Scalar] Fix assignment operator for long long.
Summary:
Assignment operator `operator=(long long)` currently allocates `sizeof(long)`.
On some platforms it works as they have `sizeof(long) == sizeof(long long)`,
but on others (e.g. Windows) it's not the case.
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D80995
Added:
Modified:
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index b6db5ccaebc4..e55aa2d4d5a4 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -331,7 +331,7 @@ Scalar &Scalar::operator=(unsigned long v) {
Scalar &Scalar::operator=(long long v) {
m_type = e_slonglong;
- m_integer = llvm::APInt(sizeof(long) * 8, v, true);
+ m_integer = llvm::APInt(sizeof(long long) * 8, v, true);
return *this;
}
diff --git a/lldb/unittests/Utility/ScalarTest.cpp b/lldb/unittests/Utility/ScalarTest.cpp
index f62173fb1401..baf1de98c121 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -188,6 +188,16 @@ TEST(ScalarTest, GetValue) {
ScalarGetValue(std::numeric_limits<unsigned long long>::max()));
}
+TEST(ScalarTest, LongLongAssigmentOperator) {
+ Scalar ull;
+ ull = std::numeric_limits<unsigned long long>::max();
+ EXPECT_EQ(std::numeric_limits<unsigned long long>::max(), ull.ULongLong());
+
+ Scalar sll;
+ sll = std::numeric_limits<signed long long>::max();
+ EXPECT_EQ(std::numeric_limits<signed long long>::max(), sll.SLongLong());
+}
+
TEST(ScalarTest, Division) {
Scalar lhs(5.0);
Scalar rhs(2.0);
More information about the lldb-commits
mailing list