[Lldb-commits] [lldb] bb6646c - [lldb/DataExtractor] Use an early return in GetMaxS64Bitfield, NFC
Vedant Kumar via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 3 15:57:52 PST 2020
Author: Vedant Kumar
Date: 2020-02-03T15:57:32-08:00
New Revision: bb6646ce0a2e59eda682f63696915d2dc7db40db
URL: https://github.com/llvm/llvm-project/commit/bb6646ce0a2e59eda682f63696915d2dc7db40db
DIFF: https://github.com/llvm/llvm-project/commit/bb6646ce0a2e59eda682f63696915d2dc7db40db.diff
LOG: [lldb/DataExtractor] Use an early return in GetMaxS64Bitfield, NFC
Shafik suggested this cleanup in https://reviews.llvm.org/D73913.
Added:
Modified:
lldb/source/Utility/DataExtractor.cpp
Removed:
################################################################################
diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp
index 794deedac24b..da886201dfc7 100644
--- a/lldb/source/Utility/DataExtractor.cpp
+++ b/lldb/source/Utility/DataExtractor.cpp
@@ -607,19 +607,18 @@ int64_t DataExtractor::GetMaxS64Bitfield(offset_t *offset_ptr, size_t size,
assert(size >= 1 && "GetMaxS64Bitfield size must be >= 1");
assert(size <= 8 && "GetMaxS64Bitfield size must be <= 8");
int64_t sval64 = GetMaxS64(offset_ptr, size);
- if (bitfield_bit_size > 0) {
- int32_t lsbcount = bitfield_bit_offset;
- if (m_byte_order == eByteOrderBig)
- lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size;
- if (lsbcount > 0)
- sval64 >>= lsbcount;
- uint64_t bitfield_mask =
- llvm::maskTrailingOnes<uint64_t>(bitfield_bit_size);
- sval64 &= bitfield_mask;
- // sign extend if needed
- if (sval64 & ((static_cast<uint64_t>(1)) << (bitfield_bit_size - 1)))
- sval64 |= ~bitfield_mask;
- }
+ if (bitfield_bit_size == 0)
+ return sval64;
+ int32_t lsbcount = bitfield_bit_offset;
+ if (m_byte_order == eByteOrderBig)
+ lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size;
+ if (lsbcount > 0)
+ sval64 >>= lsbcount;
+ uint64_t bitfield_mask = llvm::maskTrailingOnes<uint64_t>(bitfield_bit_size);
+ sval64 &= bitfield_mask;
+ // sign extend if needed
+ if (sval64 & ((static_cast<uint64_t>(1)) << (bitfield_bit_size - 1)))
+ sval64 |= ~bitfield_mask;
return sval64;
}
More information about the lldb-commits
mailing list