[Lldb-commits] [PATCH] D19535: Fix 2 LLVM assertion caoused by an API missues in Scalar
Tamas Berghammer via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 26 08:53:26 PDT 2016
tberghammer created this revision.
tberghammer added reviewers: labath, clayborg.
tberghammer added a subscriber: lldb-commits.
Fix 2 LLVM assertion caused by an API miss-ues in Scalar
APInt::trunc only works if the destination size is strictly smaller
then the source size while APInt::sext and APInt::zext only works if
the destination size is strictly larger then the source size.
http://reviews.llvm.org/D19535
Files:
source/Core/Scalar.cpp
Index: source/Core/Scalar.cpp
===================================================================
--- source/Core/Scalar.cpp
+++ source/Core/Scalar.cpp
@@ -2787,16 +2787,28 @@
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);
+ if (m_integer.getBitWidth() > bit_size)
+ m_integer = m_integer.trunc(bit_size);
+ if (m_integer.getBitWidth() < bit_size)
+ m_integer = m_integer.sext(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);
+ if (m_integer.getBitWidth() > bit_size)
+ m_integer = m_integer.trunc(bit_size);
+ if (m_integer.getBitWidth() < bit_size)
+ m_integer = m_integer.zext(8 * GetByteSize());
return true;
+ }
}
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19535.55017.patch
Type: text/x-patch
Size: 1310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160426/45e18ddb/attachment.bin>
More information about the lldb-commits
mailing list