[Lldb-commits] [lldb] r260239 - Fix invalid shift operator overload in Scalar

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 9 09:28:02 PST 2016


Author: labath
Date: Tue Feb  9 11:28:01 2016
New Revision: 260239

URL: http://llvm.org/viewvc/llvm-project?rev=260239&view=rev
Log:
Fix invalid shift operator overload in Scalar

Summary: This also fixes an infinite recursion between lldb_private::operator>> () and Scalar::operator>>= ().

Reviewers: sagar, tberghammer, labath

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D16868

Patch by Marianne Mailhot-Sarrasin

Added:
    lldb/trunk/unittests/Core/
    lldb/trunk/unittests/Core/CMakeLists.txt
    lldb/trunk/unittests/Core/ScalarTest.cpp
Modified:
    lldb/trunk/source/Core/Scalar.cpp
    lldb/trunk/unittests/CMakeLists.txt

Modified: lldb/trunk/source/Core/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=260239&r1=260238&r2=260239&view=diff
==============================================================================
--- lldb/trunk/source/Core/Scalar.cpp (original)
+++ lldb/trunk/source/Core/Scalar.cpp Tue Feb  9 11:28:01 2016
@@ -1875,7 +1875,7 @@ Scalar::operator>>= (const Scalar& rhs)
              case e_sint128:
              case e_uint128:
              {
-                 m_integer >> *rhs.m_integer.getRawData();
+                 m_integer = m_integer.ashr(*(const uint_t *)rhs.m_integer.getRawData());
                  break;
              }
         }

Modified: lldb/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/CMakeLists.txt?rev=260239&r1=260238&r2=260239&view=diff
==============================================================================
--- lldb/trunk/unittests/CMakeLists.txt (original)
+++ lldb/trunk/unittests/CMakeLists.txt Tue Feb  9 11:28:01 2016
@@ -23,6 +23,7 @@ function(add_lldb_unittest test_name)
   llvm_config(${test_name} ${LLVM_LINK_COMPONENTS})
 endfunction()
 
+add_subdirectory(Core)
 add_subdirectory(Editline)
 add_subdirectory(Expression)
 add_subdirectory(Host)

Added: lldb/trunk/unittests/Core/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/CMakeLists.txt?rev=260239&view=auto
==============================================================================
--- lldb/trunk/unittests/Core/CMakeLists.txt (added)
+++ lldb/trunk/unittests/Core/CMakeLists.txt Tue Feb  9 11:28:01 2016
@@ -0,0 +1,3 @@
+add_lldb_unittest(CoreTests
+  ScalarTest.cpp
+  )

Added: lldb/trunk/unittests/Core/ScalarTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/ScalarTest.cpp?rev=260239&view=auto
==============================================================================
--- lldb/trunk/unittests/Core/ScalarTest.cpp (added)
+++ lldb/trunk/unittests/Core/ScalarTest.cpp Tue Feb  9 11:28:01 2016
@@ -0,0 +1,32 @@
+//===-- ScalarTest.cpp ------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
+// Workaround for MSVC standard library bug, which fails to include <thread> when
+// exceptions are disabled.
+#include <eh.h>
+#endif
+
+#include "gtest/gtest.h"
+
+#include "lldb/Core/Scalar.h"
+
+using namespace lldb_private;
+
+TEST(ScalarTest, RightShiftOperator)
+{
+    int a = 0x00001000;
+    int b = 0xFFFFFFFF;
+    int c = 4;
+    Scalar a_scalar(a);
+    Scalar b_scalar(b);
+    Scalar c_scalar(c);
+    ASSERT_EQ(a >> c, a_scalar >> c_scalar);
+    ASSERT_EQ(b >> c, b_scalar >> c_scalar);
+}




More information about the lldb-commits mailing list