[Lldb-commits] [lldb] [LLDB] Add an assert to verify sign_bit_pos is within the valid range (NFC) (PR #95678)

Florian Mayer via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 17 10:56:20 PDT 2024


================
@@ -745,26 +745,25 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
 
 bool Scalar::SignExtend(uint32_t sign_bit_pos) {
   const uint32_t max_bit_pos = GetByteSize() * 8;
+  assert(sign_bit_pos < max_bit_pos);
 
-  if (sign_bit_pos < max_bit_pos) {
-    switch (m_type) {
-    case Scalar::e_void:
-    case Scalar::e_float:
-      return false;
+  switch (m_type) {
----------------
fmayer wrote:

isn't this whole thing now

```
if (m_type  != Scalar::e_int || sign_bit_pos >= max_bit_pos - 1)
  return false;

[...]
....

https://github.com/llvm/llvm-project/pull/95678


More information about the lldb-commits mailing list