[Lldb-commits] [PATCH] D20355: Avoid an assertion failure when a bit field is extracted from a value of the same size.

Bryan Chan via lldb-commits lldb-commits at lists.llvm.org
Wed May 18 02:17:24 PDT 2016


bryanpkc created this revision.
bryanpkc added a reviewer: uweigand.
bryanpkc added a subscriber: lldb-commits.

One of the cases handled by ValueObjectChild::UpdateValue() uses the entire width of the parent's scalar value as the size of the child, and extracts the child by calling Scalar::ExtractBitfield(). This seems valid but APInt::trunc(), APInt::sext() and APInt::zext() assert that the bit field must not have the same size as the parent scalar. Replacing those calls with sextOrTrunc(), zextOrTrunc(), sextOrSelf() and zextOrSelf() fixes the assertion failures.

http://reviews.llvm.org/D20355

Files:
  source/Core/Scalar.cpp

Index: source/Core/Scalar.cpp
===================================================================
--- source/Core/Scalar.cpp
+++ source/Core/Scalar.cpp
@@ -2788,15 +2788,15 @@
         case Scalar::e_slonglong:
         case Scalar::e_sint128:
         case Scalar::e_sint256:
-            m_integer = m_integer.ashr(bit_offset).trunc(bit_size).sext(8 * GetByteSize());
+            m_integer = m_integer.ashr(bit_offset).sextOrTrunc(bit_size).sextOrSelf(8 * GetByteSize());
             return true;
 
         case Scalar::e_uint:
         case Scalar::e_ulong:
         case Scalar::e_ulonglong:
         case Scalar::e_uint128:
         case Scalar::e_uint256:
-            m_integer = m_integer.lshr(bit_offset).trunc(bit_size).zext(8 * GetByteSize());
+            m_integer = m_integer.lshr(bit_offset).zextOrTrunc(bit_size).zextOrSelf(8 * GetByteSize());
             return true;
     }
     return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20355.57581.patch
Type: text/x-patch
Size: 915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160518/580c6f86/attachment.bin>


More information about the lldb-commits mailing list